diff --git a/config/install/language.content_settings.taxonomy_term.uw_vocab_audience.yml b/config/install/language.content_settings.taxonomy_term.uw_vocab_audience.yml new file mode 100644 index 0000000000000000000000000000000000000000..7c09471c80aa93a0cd7c4652aa8991c7c5bb764f --- /dev/null +++ b/config/install/language.content_settings.taxonomy_term.uw_vocab_audience.yml @@ -0,0 +1,10 @@ +langcode: en +status: true +dependencies: + config: + - taxonomy.vocabulary.uw_vocab_audience +id: taxonomy_term.uw_vocab_audience +target_entity_type_id: taxonomy_term +target_bundle: uw_vocab_audience +default_langcode: site_default +language_alterable: false diff --git a/config/install/pathauto.pattern.uw_path_audience.yml b/config/install/pathauto.pattern.uw_path_audience.yml new file mode 100644 index 0000000000000000000000000000000000000000..6c7cbf403356bfcee8d56229f0df73763d2adc46 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_audience.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_audience +label: 'Audience path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'audience/[term:name]' +selection_criteria: + 2352a426-ffc2-43c1-93ae-f6c8a726cbd3: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_vocab_audience: uw_vocab_audience + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: 2352a426-ffc2-43c1-93ae-f6c8a726cbd3 +selection_logic: and +weight: -4 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_blog_post.yml b/config/install/pathauto.pattern.uw_path_blog_post.yml new file mode 100644 index 0000000000000000000000000000000000000000..a71df6155b9bd6c2a59d1177dddb7f4a8f400b79 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_blog_post.yml @@ -0,0 +1,21 @@ +langcode: en +status: true +dependencies: + module: + - node +id: uw_path_blog_post +label: 'Blog post path pattern' +type: 'canonical_entities:node' +pattern: 'blog/[node:title]' +selection_criteria: + 6008045d-ac62-416d-a3f4-46c30aaab4d5: + id: node_type + bundles: + uw_ct_blog: uw_ct_blog + negate: false + context_mapping: + node: node + uuid: 6008045d-ac62-416d-a3f4-46c30aaab4d5 +selection_logic: and +weight: -6 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_blog_tags.yml b/config/install/pathauto.pattern.uw_path_blog_tags.yml new file mode 100644 index 0000000000000000000000000000000000000000..48a30da8e0c1ef9a239dd7134a32d91a4e22b40f --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_blog_tags.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_blog_tags +label: 'Blog tags path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'blog/tags/[term:name]' +selection_criteria: + c3139779-798a-4754-957a-35fba9bd29e3: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_vocab_blog_tags: uw_vocab_blog_tags + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: c3139779-798a-4754-957a-35fba9bd29e3 +selection_logic: and +weight: 0 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_catalog_categories.yml b/config/install/pathauto.pattern.uw_path_catalog_categories.yml new file mode 100644 index 0000000000000000000000000000000000000000..6b40b3632c116d80afff4340cd672197bd23ddae --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_catalog_categories.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_catalog_categories +label: 'Catalog categories path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'catalogs/categories/[term:name]' +selection_criteria: + f4c229ad-5155-4814-8d09-251af2ccf6ed: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_vocab_catalog_categories: uw_vocab_catalog_categories + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: f4c229ad-5155-4814-8d09-251af2ccf6ed +selection_logic: and +weight: 2 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_catalogs.yml b/config/install/pathauto.pattern.uw_path_catalogs.yml new file mode 100644 index 0000000000000000000000000000000000000000..be17d098a92e23100da5c46d2e10bb50e23ece06 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_catalogs.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_catalogs +label: 'Catalogs path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'catalogs/[term:name]' +selection_criteria: + d9203b0b-0816-4e91-b14a-db0e4c905d3e: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_vocab_catalogs: uw_vocab_catalogs + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: d9203b0b-0816-4e91-b14a-db0e4c905d3e +selection_logic: and +weight: 1 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_content.yml b/config/install/pathauto.pattern.uw_path_content.yml new file mode 100644 index 0000000000000000000000000000000000000000..117a5205ae35a770d84d41f036c56a9d6b1bbf89 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_content.yml @@ -0,0 +1,13 @@ +langcode: en +status: true +dependencies: + module: + - node +id: uw_path_content +label: 'Content path pattern' +type: 'canonical_entities:node' +pattern: '[node:menu-link:parent:url:path]/[node:title]' +selection_criteria: { } +selection_logic: and +weight: -5 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_custom_block.yml b/config/install/pathauto.pattern.uw_path_custom_block.yml new file mode 100644 index 0000000000000000000000000000000000000000..b665652ae19dd707ba885e356fa9952def0ac7e7 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_custom_block.yml @@ -0,0 +1,13 @@ +langcode: en +status: true +dependencies: + module: + - block_content +id: uw_path_custom_block +label: 'Custom block path pattern' +type: 'canonical_entities:block_content' +pattern: 'blocks/[block_content:info]' +selection_criteria: { } +selection_logic: and +weight: 6 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_event.yml b/config/install/pathauto.pattern.uw_path_event.yml new file mode 100644 index 0000000000000000000000000000000000000000..a16aa9f72328227e9e14572a2eeadfe3fd9ceffa --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_event.yml @@ -0,0 +1,21 @@ +langcode: en +status: true +dependencies: + module: + - node +id: uw_path_event +label: 'Event path pattern' +type: 'canonical_entities:node' +pattern: 'events/[node:title]' +selection_criteria: + 0f8d7153-46e2-4788-a25b-8a998481ed5d: + id: node_type + bundles: + uw_ct_event: uw_ct_event + negate: false + context_mapping: + node: node + uuid: 0f8d7153-46e2-4788-a25b-8a998481ed5d +selection_logic: and +weight: -7 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_event_tags.yml b/config/install/pathauto.pattern.uw_path_event_tags.yml new file mode 100644 index 0000000000000000000000000000000000000000..eaae101e6068d7cbbb192040a88e7a6c0d8061fa --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_event_tags.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_event_tags +label: 'Event tags path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'events/tags/[term:name]' +selection_criteria: + 391bcba7-aaaf-48f2-9045-d6b4279e2c69: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_tax_event_tags: uw_tax_event_tags + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: 391bcba7-aaaf-48f2-9045-d6b4279e2c69 +selection_logic: and +weight: -1 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_event_types.yml b/config/install/pathauto.pattern.uw_path_event_types.yml new file mode 100644 index 0000000000000000000000000000000000000000..6e9fb93f65877e68687070e155ba98b9c8a3b802 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_event_types.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_event_types +label: 'Event types path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'events/types/[term:name]' +selection_criteria: + f991675b-525d-4fc0-878b-1d1746da5a97: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_tax_event_type: uw_tax_event_type + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: f991675b-525d-4fc0-878b-1d1746da5a97 +selection_logic: and +weight: -2 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_faculties_and_schools.yml b/config/install/pathauto.pattern.uw_path_faculties_and_schools.yml new file mode 100644 index 0000000000000000000000000000000000000000..b57a0b0e1e19fa5f8558b025e36fef533c9e58ee --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_faculties_and_schools.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_faculties_and_schools +label: 'Faculties and schools path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'catalogs/faculties-and-schools/[term:name]' +selection_criteria: + e3bc433f-3689-4dee-aa47-50734405844c: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_vocab_faculties_and_schools: uw_vocab_faculties_and_schools + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: e3bc433f-3689-4dee-aa47-50734405844c +selection_logic: and +weight: 3 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_media.yml b/config/install/pathauto.pattern.uw_path_media.yml new file mode 100644 index 0000000000000000000000000000000000000000..c7390cd49a27dc82d25963a6bb19ce67199fea79 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_media.yml @@ -0,0 +1,13 @@ +langcode: en +status: true +dependencies: + module: + - media +id: uw_path_media +label: 'Media path pattern' +type: 'canonical_entities:media' +pattern: 'media/[media:name]' +selection_criteria: { } +selection_logic: and +weight: 5 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_news_item.yml b/config/install/pathauto.pattern.uw_path_news_item.yml new file mode 100644 index 0000000000000000000000000000000000000000..94e00e16b35719aef152ce5caf85fe830df1b9a8 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_news_item.yml @@ -0,0 +1,21 @@ +langcode: en +status: true +dependencies: + module: + - node +id: uw_path_news_item +label: 'News item path pattern' +type: 'canonical_entities:node' +pattern: 'news/[node:title]' +selection_criteria: + 92cc743b-f206-40a5-a6a9-4f67373876ad: + id: node_type + bundles: + uw_ct_news_item: uw_ct_news_item + negate: false + context_mapping: + node: node + uuid: 92cc743b-f206-40a5-a6a9-4f67373876ad +selection_logic: and +weight: -8 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_news_tags.yml b/config/install/pathauto.pattern.uw_path_news_tags.yml new file mode 100644 index 0000000000000000000000000000000000000000..99572f7f755950f6d2ba03406e6eecbdaec6b79a --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_news_tags.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + module: + - ctools + - taxonomy +id: uw_path_news_tags +label: 'News tags path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: 'news/tags/[term:name]' +selection_criteria: + 2d47e618-a761-4634-b743-f6924f2b81bf: + id: 'entity_bundle:taxonomy_term' + bundles: + uw_vocab_news_tags: uw_vocab_news_tags + negate: false + context_mapping: + taxonomy_term: taxonomy_term + uuid: 2d47e618-a761-4634-b743-f6924f2b81bf +selection_logic: and +weight: -3 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_sidebar.yml b/config/install/pathauto.pattern.uw_path_sidebar.yml new file mode 100644 index 0000000000000000000000000000000000000000..8f1e2022115e063ac570b9bd2b2f8953b9b6c905 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_sidebar.yml @@ -0,0 +1,21 @@ +langcode: en +status: true +dependencies: + module: + - node +id: uw_path_sidebar +label: 'Sidebar path pattern' +type: 'canonical_entities:node' +pattern: 'sidebars/[node:title]' +selection_criteria: + 96550c84-2385-43f7-aa25-ca80528ddf91: + id: node_type + bundles: + uw_ct_sidebar: uw_ct_sidebar + negate: false + context_mapping: + node: node + uuid: 96550c84-2385-43f7-aa25-ca80528ddf91 +selection_logic: and +weight: -9 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_site_footer.yml b/config/install/pathauto.pattern.uw_path_site_footer.yml new file mode 100644 index 0000000000000000000000000000000000000000..56c9953e3126cbc254f72fc6b064e29282b985af --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_site_footer.yml @@ -0,0 +1,21 @@ +langcode: en +status: true +dependencies: + module: + - node +id: uw_path_site_footer +label: 'Site footer path pattern' +type: 'canonical_entities:node' +pattern: 'site-footer/[node:title]' +selection_criteria: + 1c4af52c-2d8a-420f-a820-a89df82759ef: + id: node_type + bundles: + uw_ct_site_footer: uw_ct_site_footer + negate: false + context_mapping: + node: node + uuid: 1c4af52c-2d8a-420f-a820-a89df82759ef +selection_logic: and +weight: -10 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_taxonomy_term.yml b/config/install/pathauto.pattern.uw_path_taxonomy_term.yml new file mode 100644 index 0000000000000000000000000000000000000000..c3d98368362fa17039cb7f95f17650d1a6480613 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_taxonomy_term.yml @@ -0,0 +1,13 @@ +langcode: en +status: true +dependencies: + module: + - taxonomy +id: uw_path_taxonomy_term +label: 'Taxonomy term path pattern' +type: 'canonical_entities:taxonomy_term' +pattern: '[term:vocabulary]/[term:name]' +selection_criteria: { } +selection_logic: and +weight: 4 +relationships: { } diff --git a/config/install/pathauto.pattern.uw_path_user.yml b/config/install/pathauto.pattern.uw_path_user.yml new file mode 100644 index 0000000000000000000000000000000000000000..ed9a103ee882ec4196c210c8fe85167e97403471 --- /dev/null +++ b/config/install/pathauto.pattern.uw_path_user.yml @@ -0,0 +1,13 @@ +langcode: en +status: true +dependencies: + module: + - user +id: uw_path_user +label: 'User path pattern' +type: 'canonical_entities:user' +pattern: 'users/[user:account-name]' +selection_criteria: { } +selection_logic: and +weight: 7 +relationships: { } diff --git a/config/install/pathauto.settings.yml b/config/install/pathauto.settings.yml new file mode 100644 index 0000000000000000000000000000000000000000..6d7bc2264c6102b0e1314c5611e40eeef2a18b3c --- /dev/null +++ b/config/install/pathauto.settings.yml @@ -0,0 +1,52 @@ +enabled_entity_types: + - block_content + - user +punctuation: + double_quotes: 0 + quotes: 0 + backtick: 0 + comma: 0 + period: 0 + hyphen: 1 + underscore: 0 + colon: 0 + semicolon: 0 + pipe: 0 + left_curly: 0 + left_square: 0 + right_curly: 0 + right_square: 0 + plus: 0 + equal: 0 + asterisk: 0 + ampersand: 0 + percent: 0 + caret: 0 + dollar: 0 + hash: 0 + at: 0 + exclamation: 0 + tilde: 0 + left_parenthesis: 0 + right_parenthesis: 0 + question_mark: 0 + less_than: 0 + greater_than: 0 + slash: 0 + back_slash: 0 +verbose: false +separator: '-' +max_length: 255 +max_component_length: 60 +transliterate: true +reduce_ascii: true +case: true +ignore_words: 'a, an, as, at, before, but, by, for, from, is, in, into, like, of, off, on, onto, per, since, than, the, this, that, to, up, via, with, le, la, l, les, un, une, des, du, de' +update_action: 2 +safe_tokens: + - alias + - path + - join-path + - login-url + - url + - url-brief diff --git a/config/install/taxonomy.vocabulary.uw_vocab_audience.yml b/config/install/taxonomy.vocabulary.uw_vocab_audience.yml new file mode 100644 index 0000000000000000000000000000000000000000..bf7bc2a4d4b4e15c3c73073f43ff949ad2cf3617 --- /dev/null +++ b/config/install/taxonomy.vocabulary.uw_vocab_audience.yml @@ -0,0 +1,7 @@ +langcode: en +status: true +dependencies: { } +name: Audience +vid: uw_vocab_audience +description: 'Who does this content apply to?' +weight: 0 diff --git a/config/install/user.role.uw_role_content_author.yml b/config/install/user.role.uw_role_content_author.yml index abca3cf882ba8279948cc6af3b113d66a2e793fc..980e028dc15c4434aad9c26b9a270db182377a41 100644 --- a/config/install/user.role.uw_role_content_author.yml +++ b/config/install/user.role.uw_role_content_author.yml @@ -40,7 +40,10 @@ permissions: - 'create paragraph content uw_para_ff' - 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_type' + - 'create terms in uw_vocab_audience' - 'create terms in uw_vocab_blog_tags' + - 'create terms in uw_vocab_catalog_categories' + - 'create terms in uw_vocab_catalogs' - 'create terms in uw_vocab_news_tags' - 'create url aliases' - 'create uw_ct_blog content' @@ -74,7 +77,10 @@ permissions: - 'edit own uw_news_item content' - 'edit terms in uw_tax_event_tags' - 'edit terms in uw_tax_event_type' + - 'edit terms in uw_vocab_audience' - 'edit terms in uw_vocab_blog_tags' + - 'edit terms in uw_vocab_catalog_categories' + - 'edit terms in uw_vocab_catalogs' - 'edit terms in uw_vocab_news_tags' - 'make smart dates recur' - 'reschedule smart date recur instances' diff --git a/config/install/user.role.uw_role_content_editor.yml b/config/install/user.role.uw_role_content_editor.yml index bb2eca623d081fa6caa3c85449ed7602570f8453..269b69361e42eb29232df67531afb284db7925f4 100644 --- a/config/install/user.role.uw_role_content_editor.yml +++ b/config/install/user.role.uw_role_content_editor.yml @@ -41,7 +41,10 @@ permissions: - 'create paragraph content uw_para_ff' - 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_type' + - 'create terms in uw_vocab_audience' - 'create terms in uw_vocab_blog_tags' + - 'create terms in uw_vocab_catalog_categories' + - 'create terms in uw_vocab_catalogs' - 'create terms in uw_vocab_news_tags' - 'create url aliases' - 'create uw_ct_blog content' @@ -75,7 +78,10 @@ permissions: - 'edit own uw_news_item content' - 'edit terms in uw_tax_event_tags' - 'edit terms in uw_tax_event_type' + - 'edit terms in uw_vocab_audience' - 'edit terms in uw_vocab_blog_tags' + - 'edit terms in uw_vocab_catalog_categories' + - 'edit terms in uw_vocab_catalogs' - 'edit terms in uw_vocab_news_tags' - 'make smart dates recur' - 'reschedule smart date recur instances' diff --git a/config/install/user.role.uw_role_site_manager.yml b/config/install/user.role.uw_role_site_manager.yml index 3a84ebcb2796f9e683cafe5e191ba614f2657972..c99b9fcb043fcb2c59e960e76b6c2b30f663eb1b 100644 --- a/config/install/user.role.uw_role_site_manager.yml +++ b/config/install/user.role.uw_role_site_manager.yml @@ -42,7 +42,10 @@ permissions: - 'create paragraph content uw_para_ff' - 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_type' + - 'create terms in uw_vocab_audience' - 'create terms in uw_vocab_blog_tags' + - 'create terms in uw_vocab_catalog_categories' + - 'create terms in uw_vocab_catalogs' - 'create terms in uw_vocab_news_tags' - 'create url aliases' - 'create uw_ct_blog content' @@ -79,7 +82,10 @@ permissions: - 'delete paragraph content uw_para_ff' - 'delete terms in uw_tax_event_tags' - 'delete terms in uw_tax_event_type' + - 'delete terms in uw_vocab_audience' - 'delete terms in uw_vocab_blog_tags' + - 'delete terms in uw_vocab_catalog_categories' + - 'delete terms in uw_vocab_catalogs' - 'delete terms in uw_vocab_news_tags' - 'delete uw_news_item revisions' - 'edit any uw_ct_blog content' @@ -98,7 +104,10 @@ permissions: - 'edit own uw_news_item content' - 'edit terms in uw_tax_event_tags' - 'edit terms in uw_tax_event_type' + - 'edit terms in uw_vocab_audience' - 'edit terms in uw_vocab_blog_tags' + - 'edit terms in uw_vocab_catalog_categories' + - 'edit terms in uw_vocab_catalogs' - 'edit terms in uw_vocab_news_tags' - 'make smart dates recur' - 'reschedule smart date recur instances' diff --git a/uw_cfg_common.info.yml b/uw_cfg_common.info.yml index 5d51692b9e07eb81df3ac8f50db3842192f42902..fe7fa29c40290f871392207781ebeb3bbd0a4aae 100644 --- a/uw_cfg_common.info.yml +++ b/uw_cfg_common.info.yml @@ -15,6 +15,7 @@ dependencies: - filter - hcaptcha - hook_event_dispatcher + - language - layout_builder - layout_builder_browser - layout_builder_modal @@ -23,6 +24,8 @@ dependencies: - linkit - media - node + - pathauto - preprocess_event_dispatcher + - taxonomy - user - views diff --git a/uw_cfg_common.install b/uw_cfg_common.install index fd0636c921a85af5ee676b7587988260c7e34c3d..22a8f5e07651db13044d3237b5716b2913986253 100644 --- a/uw_cfg_common.install +++ b/uw_cfg_common.install @@ -95,4 +95,82 @@ function uw_cfg_common_install() { ], ]; UwPermissions::grantRevoke($permissions_to_process, 'grant'); + + // Add terms to the vocabulary 'uw_vocab_audience'. + $terms = [ + 'Current students' => [ + 'Current undergraduate students', + 'Current graduate students', + ], + 'Future students' => [ + 'Future undergraduate students', + 'Future graduate students', + ], + 'Faculty', + 'Staff', + 'Alumni', + 'Parents', + 'Donors | Friends | Supporters', + 'Employers', + 'International', + 'Media', + ]; + + $weight = 0; + foreach ($terms as $key => $term) { + if (is_array($term)) { + $parent = _uw_cfg_common_create_term($key, 'uw_vocab_audience', $weight, []); + + foreach ($term as $child) { + _uw_cfg_common_create_term($child, 'uw_vocab_audience', $weight, [$parent]); + } + } + else { + _uw_cfg_common_create_term($term, 'uw_vocab_audience', $weight, []); + } + $weight++; + } +} + +/** + * @file + * Contains various helper functions. + */ + +/** + * Helper function to create a taxonomy term programmatically. + * + * @code + * // Create top level term + * $term_id = _nodemaker_term_create('My Term', 'my_vocab', 0, []); + * + * // Create term with parent term with an id of 999 + * $term_id = _nodemaker_term_create('My Term', 'my_vocab', 0, [999]); + * @endcode + * + * @param string $term + * - Term Name. + * @param string $vocabulary + * - System id of the vocabulary term will be added to. + * @param array $parent + * - Array of term ids to be assigned as parent. + * + * @return int|null + * - Returns the term id of the created term on success, null on failure. + */ +function _uw_cfg_common_create_term($taxonomy_name, $vocab_machine_name, $weight, array $parent_tid = []) { + + // Create the taxonomy term. + $new_term = Drupal\taxonomy\Entity\Term::create([ + 'name' => $taxonomy_name, + 'vid' => $vocab_machine_name, + 'parent' => $parent_tid, + 'weight' => $weight, + ]); + + // Save the taxonomy term. + $new_term->save(); + + // Return the taxonomy term id. + return $new_term->id(); }