Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

[SDPAP-8421] Apply content category field and taxonomy #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions config/install/core.entity_form_display.node.grant.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
- field.field.node.grant.field_show_social_sharing
- field.field.node.grant.field_tags
- field.field.node.grant.field_topic
- field.field.node.grant.field_content_category
- node.type.grant
module:
- content_moderation
Expand All @@ -44,6 +45,7 @@ dependencies:
- range
- telephone
- text
- term_reference_tree
third_party_settings:
field_group:
group_grant_overview:
Expand Down Expand Up @@ -481,6 +483,17 @@ content:
third_party_settings: { }
type: entity_reference_autocomplete
region: content
field_content_category:
type: term_reference_tree
weight: 1
region: content
settings:
start_minimized: true
leaves_only: true
select_parents: false
cascading_selection: 0
max_depth: 0
third_party_settings: { }
moderation_state:
type: moderation_state_default
weight: 9
Expand Down
28 changes: 28 additions & 0 deletions config/install/field.field.node.grant.field_content_category.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_content_category
- node.type.grant
- taxonomy.vocabulary.content_category
id: node.grant.field_content_category
field_name: field_content_category
entity_type: node
bundle: grant
label: 'Content category'
description: 'Select the most relevant option from the <a href="https://www.vic.gov.au/content-categories">list of content categories</a>. This mandatory field will help with search and filtering on the website.'
required: true
translatable: true
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
content_category: content_category
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference
8 changes: 8 additions & 0 deletions src/TideGrantOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,12 @@ public function assignNecessaryPermissions() {
}
}

/**
* Add default value to Content Category.
*/
public function addDefaultValueToContentCategory() {
\Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/updates');
_tide_core_field_content_category_default_value('grant', 'Grant');
}

}
28 changes: 28 additions & 0 deletions tide_grant.install
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function tide_grant_install() {
$grantoperation->addGrantAuthorUser();
$grantoperation->assignNecessaryPermissions();
$grantoperation->enableEditorialWorkflow();
$grantoperation->addDefaultValueToContentCategory();
}

/**
Expand All @@ -35,3 +36,30 @@ function tide_grant_uninstall() {
// Remove the image styles that Linkit has installed.
$config_factory->getEditable('user.role.grant_author')->delete();
}

/**
* Implements hook_update_dependencies().
*/
function tide_grant_update_dependencies() {
$dependencies = [];
$dependencies['tide_grant'][10001] = ['tide_core' => 10005];
return $dependencies;
}

/**
* Imports field.field.node.grant.field_content_category for existing sites.
*/
function tide_grant_update_10001() {
\Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_grant') . '/config/install'];
$config_read = _tide_read_config('field.field.node.grant.field_content_category', $config_location, TRUE);
$storage = \Drupal::entityTypeManager()->getStorage('field_config');
$id = $storage->getIDFromConfigName('field.field.node.grant.field_content_category', $storage->getEntityType()->getConfigPrefix());
if ($storage->load($id) == NULL) {
$config_entity = $storage->createFromStorageRecord($config_read);
$config_entity->save();
}
\Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/updates');
_tide_core_field_content_category_default_value('grant', 'Grant');
_tide_core_content_category_form_display('grant');
}
Loading