-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDPAP-8421]Adds content category terms.
https://digital-vic.atlassian.net/browse/SDPAP-8421 1. adding content category definition and terms. 2. enable term_reference_tree module add comments Modifies field_content_category’s help text update dev-tools content category helpers for other modules update _tide_core_adding_default_taxonomy() Remove fixed patch restructure helper functions.
- Loading branch information
1 parent
990e986
commit ae374c9
Showing
9 changed files
with
332 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
config/install/field.storage.node.field_content_category.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
langcode: en | ||
status: true | ||
dependencies: | ||
module: | ||
- field_permissions | ||
- node | ||
- taxonomy | ||
third_party_settings: | ||
field_permissions: | ||
permission_type: public | ||
id: node.field_content_category | ||
field_name: field_content_category | ||
entity_type: node | ||
type: entity_reference | ||
settings: | ||
target_type: taxonomy_term | ||
module: core | ||
locked: false | ||
cardinality: -1 | ||
translatable: true | ||
indexes: { } | ||
persist_with_no_fields: false | ||
custom_storage: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
langcode: en | ||
status: true | ||
dependencies: { } | ||
name: 'Content category' | ||
vid: content_category | ||
description: 'Categories assigned to all content to assist with filtering in content collection and search' | ||
weight: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* This file supports other modules in their hook_update_N. | ||
*/ | ||
|
||
use Drupal\Core\Entity\Entity\EntityFormDisplay; | ||
use Drupal\field\Entity\FieldConfig; | ||
use Drupal\taxonomy\Entity\Term; | ||
|
||
/** | ||
* Set default value for field_content_category field. | ||
*/ | ||
function _tide_core_field_content_category_default_value(string $bundle, string $term_name) { | ||
$query = \Drupal::entityQuery('taxonomy_term')->condition('name', $term_name) | ||
->condition('vid', 'content_category') | ||
->condition('parent', 0, '<>') | ||
->accessCheck(TRUE); | ||
$results = $query->execute(); | ||
if (!empty($results)) { | ||
$tid = reset($results); | ||
$uuid = Term::load($tid)->uuid(); | ||
/** @var \Drupal\field\Entity\FieldConfig $config */ | ||
$config = FieldConfig::loadByName('node', $bundle, 'field_content_category'); | ||
if (!empty($uuid)) { | ||
$config->set('default_value', [['target_uuid' => $uuid]])->save(); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Set form display for field_content_category field. | ||
*/ | ||
function _tide_core_content_category_form_display(string $bundle) { | ||
$entity_form_display = EntityFormDisplay::load('node.' . $bundle . '.default'); | ||
$detail = $entity_form_display->getComponent('field_tags'); | ||
$weight = $detail['weight']; | ||
$content = [ | ||
"type" => "term_reference_tree", | ||
"weight" => $weight + 1, | ||
"region" => "content", | ||
"settings" => [ | ||
"start_minimized" => TRUE, | ||
"leaves_only" => TRUE, | ||
"select_parents" => FALSE, | ||
"cascading_selection" => 0, | ||
"max_depth" => 0, | ||
], | ||
"third_party_settings" => [], | ||
]; | ||
$field_content_category_component = $entity_form_display->getComponent('field_content_category'); | ||
if ($field_content_category_component === NULL) { | ||
$entity_form_display->setComponent('field_content_category', $content)->save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters