Skip to content

Commit b5abdfc

Browse files
authored
VACMS-11147 11148 11146: Convert outreach materials categories to taxonomy terms (#11352)
* VACMS-11147: Add the new Related Benefits field to Publications. * VACMS-11147: Add update hook to migrate from field_benefits to field_lc_categories in Publication nodes. * VACMS-11146: Add fields to r&s taxonomy. * VACMS-11146: Add update hook to populate new R&S vocabulary fields. * VACMS-11147: Move field-dependant update hooks to deploy hooks. * VACMS-11147: Moves deploy hooks to correct location in va_gov_db. * VACMS-11147: Moves revision_log to the editorial workflow wrapper. * VACMS-11147: Adds PACT Act to R&S categories vocab and corrects data migration mapping from field_benefits. * VACMS-11147: Add the pact act term to the R&S Categories vocab in related update hook. * VACMS-11147: Add new fields to vocabulary behat tests. * VACMS-11147: Add new related benefits field to content fields spect tool behat test. * VACMS-11147: Corrects the exception message in _va_gov_db_uninstall_modules(). * VACMS-11147: Completes the field rename for 'Related Benefits'. * VACMS-11147: Corrects faulty entity_views_display config, removing errant entry. * VACMS-11147: Refactors field migration to leverage existing script-library.php scripts. * VACMS-11147: Moves install and deploy hooks to va_gov_resources_and_support. * VACMS-11147: Removes hidden attribute for related benefits ref field. * VACMS-11147: PHPCS and PHPUnit fixes. * VACMS0-11147: Restores missing function; cleans up whitespace on feature tests. * VACMS-11147: Ignores phpstan missing property error in va_gov_resources_and_support. Resolves function not found by adding scanFiles directive to phpstan to include script-library.php. * VACMS-11147: Renames _va_gov_stringifynid -> _va_gov_db_stringifynid to avoid duplicate function error being thrown by phpunit. Co-authored-by: Daniel Sasser <[email protected]>
1 parent 9b62076 commit b5abdfc

19 files changed

+437
-16
lines changed

config/sync/core.entity_form_display.node.outreach_asset.default.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies:
77
- field.field.node.outreach_asset.field_benefits
88
- field.field.node.outreach_asset.field_description
99
- field.field.node.outreach_asset.field_format
10+
- field.field.node.outreach_asset.field_lc_categories
1011
- field.field.node.outreach_asset.field_listing
1112
- field.field.node.outreach_asset.field_media
1213
- field.field.node.outreach_asset.field_meta_tags
@@ -25,7 +26,7 @@ third_party_settings:
2526
label: 'Section settings'
2627
region: content
2728
parent_name: ''
28-
weight: 12
29+
weight: 13
2930
format_type: details_sidebar
3031
format_settings:
3132
classes: ''
@@ -40,7 +41,7 @@ third_party_settings:
4041
label: 'Editorial workflow'
4142
region: content
4243
parent_name: ''
43-
weight: 11
44+
weight: 12
4445
format_type: fieldset
4546
format_settings:
4647
classes: ''
@@ -53,7 +54,7 @@ third_party_settings:
5354
label: 'Meta Tags'
5455
region: content
5556
parent_name: ''
56-
weight: 10
57+
weight: 11
5758
format_type: fieldset
5859
format_settings:
5960
classes: ''
@@ -91,6 +92,12 @@ content:
9192
region: content
9293
settings: { }
9394
third_party_settings: { }
95+
field_lc_categories:
96+
type: options_select
97+
weight: 10
98+
region: content
99+
settings: { }
100+
third_party_settings: { }
94101
field_listing:
95102
type: options_select
96103
weight: 1

config/sync/core.entity_form_display.taxonomy_term.lc_categories.default.yml

+18
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ langcode: en
33
status: true
44
dependencies:
55
config:
6+
- field.field.taxonomy_term.lc_categories.field_enforce_unique_value
7+
- field.field.taxonomy_term.lc_categories.field_topic_id
68
- taxonomy.vocabulary.lc_categories
79
module:
10+
- allow_only_one
811
- path
912
- text
1013
id: taxonomy_term.lc_categories.default
@@ -20,6 +23,21 @@ content:
2023
rows: 5
2124
placeholder: ''
2225
third_party_settings: { }
26+
field_enforce_unique_value:
27+
type: allow_only_one_widget
28+
weight: 3
29+
region: content
30+
settings:
31+
size: 1
32+
third_party_settings: { }
33+
field_topic_id:
34+
type: string_textfield
35+
weight: 4
36+
region: content
37+
settings:
38+
size: 60
39+
placeholder: ''
40+
third_party_settings: { }
2341
name:
2442
type: string_textfield
2543
weight: 0

config/sync/core.entity_view_display.node.outreach_asset.default.yml

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies:
77
- field.field.node.outreach_asset.field_benefits
88
- field.field.node.outreach_asset.field_description
99
- field.field.node.outreach_asset.field_format
10+
- field.field.node.outreach_asset.field_lc_categories
1011
- field.field.node.outreach_asset.field_listing
1112
- field.field.node.outreach_asset.field_media
1213
- field.field.node.outreach_asset.field_meta_tags
@@ -41,6 +42,14 @@ content:
4142
third_party_settings: { }
4243
weight: 0
4344
region: content
45+
field_lc_categories:
46+
type: entity_reference_label
47+
label: above
48+
settings:
49+
link: true
50+
third_party_settings: { }
51+
weight: 5
52+
region: content
4453
field_media:
4554
type: entity_reference_entity_view
4655
label: above
@@ -53,6 +62,7 @@ content:
5362
hidden:
5463
content_moderation_control: true
5564
field_administration: true
65+
field_lc_categories: true
5666
field_listing: true
5767
field_meta_tags: true
5868
links: true

config/sync/core.entity_view_display.node.outreach_asset.teaser.yml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies:
88
- field.field.node.outreach_asset.field_benefits
99
- field.field.node.outreach_asset.field_description
1010
- field.field.node.outreach_asset.field_format
11+
- field.field.node.outreach_asset.field_lc_categories
1112
- field.field.node.outreach_asset.field_listing
1213
- field.field.node.outreach_asset.field_media
1314
- field.field.node.outreach_asset.field_meta_tags
@@ -30,6 +31,7 @@ hidden:
3031
field_benefits: true
3132
field_description: true
3233
field_format: true
34+
field_lc_categories: true
3335
field_listing: true
3436
field_media: true
3537
field_meta_tags: true

config/sync/core.entity_view_display.taxonomy_term.lc_categories.default.yml

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ langcode: en
33
status: true
44
dependencies:
55
config:
6+
- field.field.taxonomy_term.lc_categories.field_enforce_unique_value
7+
- field.field.taxonomy_term.lc_categories.field_topic_id
68
- taxonomy.vocabulary.lc_categories
7-
- views.view.taxonomy_term
89
module:
10+
- allow_only_one
911
- layout_builder
10-
- layout_discovery
1112
- text
12-
- views
1313
third_party_settings:
1414
layout_builder:
1515
enabled: false
@@ -26,5 +26,20 @@ content:
2626
third_party_settings: { }
2727
weight: 0
2828
region: content
29+
field_enforce_unique_value:
30+
type: allow_only_one
31+
label: above
32+
settings: { }
33+
third_party_settings: { }
34+
weight: 1
35+
region: content
36+
field_topic_id:
37+
type: string
38+
label: above
39+
settings:
40+
link_to_entity: false
41+
third_party_settings: { }
42+
weight: 2
43+
region: content
2944
hidden:
3045
search_api_excerpt: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
uuid: 2263639c-8aff-4bbe-af19-a51fb8d74024
2+
langcode: en
3+
status: true
4+
dependencies:
5+
config:
6+
- field.storage.node.field_lc_categories
7+
- node.type.outreach_asset
8+
- taxonomy.vocabulary.lc_categories
9+
module:
10+
- entity_reference_validators
11+
- epp
12+
third_party_settings:
13+
entity_reference_validators:
14+
circular_reference: false
15+
circular_reference_deep: false
16+
duplicate_reference: false
17+
epp:
18+
value: ''
19+
on_update: 0
20+
id: node.outreach_asset.field_lc_categories
21+
field_name: field_lc_categories
22+
entity_type: node
23+
bundle: outreach_asset
24+
label: 'Related Benefits'
25+
description: ''
26+
required: false
27+
translatable: false
28+
default_value: { }
29+
default_value_callback: ''
30+
settings:
31+
handler: 'default:taxonomy_term'
32+
handler_settings:
33+
target_bundles:
34+
lc_categories: lc_categories
35+
sort:
36+
field: name
37+
direction: asc
38+
auto_create: false
39+
auto_create_bundle: ''
40+
field_type: entity_reference
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
uuid: 70c1d053-4fc6-4ae2-b3f0-fcc2f3807496
2+
langcode: en
3+
status: true
4+
dependencies:
5+
config:
6+
- field.storage.taxonomy_term.field_enforce_unique_value
7+
- taxonomy.vocabulary.lc_categories
8+
module:
9+
- allow_only_one
10+
- epp
11+
third_party_settings:
12+
allow_only_one:
13+
field_topic_id: 1
14+
title: 0
15+
case_sensitive: null
16+
epp:
17+
value: ''
18+
on_update: 0
19+
id: taxonomy_term.lc_categories.field_enforce_unique_value
20+
field_name: field_enforce_unique_value
21+
entity_type: taxonomy_term
22+
bundle: lc_categories
23+
label: 'Enforce Unique Value'
24+
description: ''
25+
required: false
26+
translatable: false
27+
default_value:
28+
-
29+
value: 0
30+
default_value_callback: ''
31+
settings: { }
32+
field_type: allow_only_one
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
uuid: a631caae-4b20-4504-988e-84f7f98ac966
2+
langcode: en
3+
status: true
4+
dependencies:
5+
config:
6+
- field.storage.taxonomy_term.field_topic_id
7+
- taxonomy.vocabulary.lc_categories
8+
module:
9+
- epp
10+
third_party_settings:
11+
epp:
12+
value: ''
13+
on_update: 0
14+
id: taxonomy_term.lc_categories.field_topic_id
15+
field_name: field_topic_id
16+
entity_type: taxonomy_term
17+
bundle: lc_categories
18+
label: 'Topic ID'
19+
description: 'A unique id for this topic used for analytics. Must not be changed once created.'
20+
required: true
21+
translatable: false
22+
default_value: { }
23+
default_value_callback: ''
24+
settings: { }
25+
field_type: string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
uuid: fc1b15c9-91ea-426c-b404-da78e200780a
2+
langcode: en
3+
status: true
4+
dependencies:
5+
module:
6+
- node
7+
- taxonomy
8+
id: node.field_lc_categories
9+
field_name: field_lc_categories
10+
entity_type: node
11+
type: entity_reference
12+
settings:
13+
target_type: taxonomy_term
14+
module: core
15+
locked: false
16+
cardinality: -1
17+
translatable: true
18+
indexes: { }
19+
persist_with_no_fields: false
20+
custom_storage: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
uuid: 8775129d-5a0f-4953-a71c-699f6eb3c71f
2+
langcode: en
3+
status: true
4+
dependencies:
5+
module:
6+
- allow_only_one
7+
- taxonomy
8+
id: taxonomy_term.field_enforce_unique_value
9+
field_name: field_enforce_unique_value
10+
entity_type: taxonomy_term
11+
type: allow_only_one
12+
settings: { }
13+
module: allow_only_one
14+
locked: false
15+
cardinality: 1
16+
translatable: true
17+
indexes: { }
18+
persist_with_no_fields: false
19+
custom_storage: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
uuid: ca71d225-b049-42d2-8a5a-c45621015f40
2+
langcode: en
3+
status: true
4+
dependencies:
5+
module:
6+
- taxonomy
7+
id: taxonomy_term.field_topic_id
8+
field_name: field_topic_id
9+
entity_type: taxonomy_term
10+
type: string
11+
settings:
12+
max_length: 255
13+
case_sensitive: false
14+
is_ascii: false
15+
module: core
16+
locked: false
17+
cardinality: 1
18+
translatable: true
19+
indexes: { }
20+
persist_with_no_fields: false
21+
custom_storage: false

docroot/modules/custom/va_gov_db/va_gov_db.install

+4-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function _va_gov_db_uninstall_modules(array $modules, $uninstall_dependents = TR
4242
else {
4343
// Something went wrong. Throw exception.
4444
throw new UpdateException(
45-
t("Failed to uninstall the requested modules: @modules", ['@modules' => $modules_list])
45+
"Failed to uninstall the requested modules: " . implode(',', $modules_list)
4646
);
4747
}
4848
}
@@ -69,7 +69,7 @@ function _va_gov_db_install_modules(array $modules, $install_dependents = TRUE)
6969
else {
7070
// Something went wrong. Throw exception.
7171
throw new UpdateException(
72-
t("Failed to install the requested modules: @modules", ['@modules' => $modules_list])
72+
"Failed to install the requested modules: " . implode(',', $modules_list)
7373
);
7474
}
7575
}
@@ -529,7 +529,6 @@ function va_gov_db_update_8019(&$sandbox) {
529529
* Clear Drupal status report mis-matched entity/field errors.
530530
*/
531531
function va_gov_db_update_8020() {
532-
$messages = [];
533532

534533
$missing_entity_types = [
535534
'environment_indicator',
@@ -701,7 +700,7 @@ function va_gov_db_update_8027(&$sandbox) {
701700
->condition('type', 'health_care_region_detail_page')
702701
->execute();
703702
$count = 0;
704-
foreach ($nids as $key => $nid) {
703+
foreach ($nids as $nid) {
705704
if ($key_value->get($nid) == 0) {
706705
$key_value->set($nid, 1);
707706
$count++;
@@ -761,7 +760,7 @@ function va_gov_db_update_8030(&$sandbox) {
761760
->condition('type', 'leadership_listing')
762761
->execute();
763762
$count = 0;
764-
foreach ($nids as $key => $nid) {
763+
foreach ($nids as $nid) {
765764
if ($key_value->get($nid) == 0) {
766765
$key_value->set($nid, 1);
767766
$count++;

docroot/modules/custom/va_gov_db/va_gov_db.post_update.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ function va_gov_db_post_update_resave_facility_nodes(&$sandbox) {
2727
$result_count = count($nids_to_update);
2828
$sandbox['total'] = $result_count;
2929
$sandbox['current'] = 0;
30-
$prefix = 'node_';
3130
$sandbox['nids_to_update'] = array_combine(
32-
array_map('_va_gov_stringifynid', array_values($nids_to_update)),
31+
array_map('_va_gov_db_stringifynid', array_values($nids_to_update)),
3332
array_values($nids_to_update));
3433
}
3534

@@ -103,6 +102,6 @@ function va_gov_db_post_update_strip_trailing_redirect_slashes() {
103102
* @return string
104103
* The node id concatenated to the end o node_
105104
*/
106-
function _va_gov_stringifynid($nid) {
105+
function _va_gov_db_stringifynid($nid) {
107106
return "node_$nid";
108107
}

0 commit comments

Comments
 (0)