Commit d3cc92c2 authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch '1.0.x' into prod/1.0.x

parents c4a5c272 5b256ecb
......@@ -7,7 +7,6 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\Node;
use Drupal\taxonomy\Entity\Term;
/**
* Implements hook_install().
......@@ -28,48 +27,12 @@ function uw_ct_event_install() {
'Workshop',
];
$weight = 0;
foreach ($types as $type) {
_uw_ct_event_term_create($type, 'uw_tax_event_type', []);
_uw_cfg_common_create_term($type, 'uw_tax_event_type', $weight, []);
}
}
/**
* Helper function to create a taxonomy term programmatically.
*
* @code
* // Create top level term
* $term_id = _nodemaker_term_create('My Term', 'my_vocab', []);
*
* // Create term with parent term with an id of 999
* $term_id = _nodemaker_term_create('My Term', 'my_vocab', [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_ct_event_term_create($term, $vocabulary, array $parent = []) {
// Create the taxonomy term.
$new_term = Term::create([
'name' => $term,
'vid' => $vocabulary,
'parent' => $parent,
]);
// Save the taxonomy term.
$new_term->save();
// Return the taxonomy term id.
return $new_term->id();
}
/**
* Removes the first and last section from events.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment