Skip to content
Snippets Groups Projects
Commit f3e934e1 authored by Igor Biki's avatar Igor Biki
Browse files

Merge branch 'feature/ISTWCMS-4156-l26yan-Set-up-catalogs-terms' into '8.x-1.x'

Feature/istwcms 4156 l26yan set up catalogs terms

See merge request !3
parents ac4e4f19 7242e85a
No related branches found
No related tags found
1 merge request!3Feature/istwcms 4156 l26yan set up catalogs terms
langcode: en
status: true
dependencies: { }
name: Audience
vid: uw_vocab_audience
description: 'Who does this content apply to?'
weight: 0
...@@ -40,7 +40,10 @@ permissions: ...@@ -40,7 +40,10 @@ permissions:
- 'create paragraph content uw_para_ff' - 'create paragraph content uw_para_ff'
- 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type' - '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_blog_tags'
- 'create terms in uw_vocab_catalog_categories'
- 'create terms in uw_vocab_catalogs'
- 'create terms in uw_vocab_news_tags' - 'create terms in uw_vocab_news_tags'
- 'create url aliases' - 'create url aliases'
- 'create uw_ct_blog content' - 'create uw_ct_blog content'
...@@ -74,7 +77,10 @@ permissions: ...@@ -74,7 +77,10 @@ permissions:
- 'edit own uw_news_item content' - 'edit own uw_news_item content'
- 'edit terms in uw_tax_event_tags' - 'edit terms in uw_tax_event_tags'
- 'edit terms in uw_tax_event_type' - '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_blog_tags'
- 'edit terms in uw_vocab_catalog_categories'
- 'edit terms in uw_vocab_catalogs'
- 'edit terms in uw_vocab_news_tags' - 'edit terms in uw_vocab_news_tags'
- 'make smart dates recur' - 'make smart dates recur'
- 'reschedule smart date recur instances' - 'reschedule smart date recur instances'
......
...@@ -41,7 +41,10 @@ permissions: ...@@ -41,7 +41,10 @@ permissions:
- 'create paragraph content uw_para_ff' - 'create paragraph content uw_para_ff'
- 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type' - '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_blog_tags'
- 'create terms in uw_vocab_catalog_categories'
- 'create terms in uw_vocab_catalogs'
- 'create terms in uw_vocab_news_tags' - 'create terms in uw_vocab_news_tags'
- 'create url aliases' - 'create url aliases'
- 'create uw_ct_blog content' - 'create uw_ct_blog content'
...@@ -75,7 +78,10 @@ permissions: ...@@ -75,7 +78,10 @@ permissions:
- 'edit own uw_news_item content' - 'edit own uw_news_item content'
- 'edit terms in uw_tax_event_tags' - 'edit terms in uw_tax_event_tags'
- 'edit terms in uw_tax_event_type' - '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_blog_tags'
- 'edit terms in uw_vocab_catalog_categories'
- 'edit terms in uw_vocab_catalogs'
- 'edit terms in uw_vocab_news_tags' - 'edit terms in uw_vocab_news_tags'
- 'make smart dates recur' - 'make smart dates recur'
- 'reschedule smart date recur instances' - 'reschedule smart date recur instances'
......
...@@ -42,7 +42,10 @@ permissions: ...@@ -42,7 +42,10 @@ permissions:
- 'create paragraph content uw_para_ff' - 'create paragraph content uw_para_ff'
- 'create terms in uw_tax_event_tags' - 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type' - '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_blog_tags'
- 'create terms in uw_vocab_catalog_categories'
- 'create terms in uw_vocab_catalogs'
- 'create terms in uw_vocab_news_tags' - 'create terms in uw_vocab_news_tags'
- 'create url aliases' - 'create url aliases'
- 'create uw_ct_blog content' - 'create uw_ct_blog content'
...@@ -79,7 +82,10 @@ permissions: ...@@ -79,7 +82,10 @@ permissions:
- 'delete paragraph content uw_para_ff' - 'delete paragraph content uw_para_ff'
- 'delete terms in uw_tax_event_tags' - 'delete terms in uw_tax_event_tags'
- 'delete terms in uw_tax_event_type' - '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_blog_tags'
- 'delete terms in uw_vocab_catalog_categories'
- 'delete terms in uw_vocab_catalogs'
- 'delete terms in uw_vocab_news_tags' - 'delete terms in uw_vocab_news_tags'
- 'delete uw_news_item revisions' - 'delete uw_news_item revisions'
- 'edit any uw_ct_blog content' - 'edit any uw_ct_blog content'
...@@ -98,7 +104,10 @@ permissions: ...@@ -98,7 +104,10 @@ permissions:
- 'edit own uw_news_item content' - 'edit own uw_news_item content'
- 'edit terms in uw_tax_event_tags' - 'edit terms in uw_tax_event_tags'
- 'edit terms in uw_tax_event_type' - '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_blog_tags'
- 'edit terms in uw_vocab_catalog_categories'
- 'edit terms in uw_vocab_catalogs'
- 'edit terms in uw_vocab_news_tags' - 'edit terms in uw_vocab_news_tags'
- 'make smart dates recur' - 'make smart dates recur'
- 'reschedule smart date recur instances' - 'reschedule smart date recur instances'
......
...@@ -15,6 +15,7 @@ dependencies: ...@@ -15,6 +15,7 @@ dependencies:
- filter - filter
- hcaptcha - hcaptcha
- hook_event_dispatcher - hook_event_dispatcher
- language
- layout_builder - layout_builder
- layout_builder_browser - layout_builder_browser
- layout_builder_modal - layout_builder_modal
...@@ -23,6 +24,8 @@ dependencies: ...@@ -23,6 +24,8 @@ dependencies:
- linkit - linkit
- media - media
- node - node
- pathauto
- preprocess_event_dispatcher - preprocess_event_dispatcher
- taxonomy
- user - user
- views - views
...@@ -95,4 +95,82 @@ function uw_cfg_common_install() { ...@@ -95,4 +95,82 @@ function uw_cfg_common_install() {
], ],
]; ];
UwPermissions::grantRevoke($permissions_to_process, 'grant'); 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();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment