Commit 3b9500d7 authored by Igor Biki's avatar Igor Biki
Browse files

Merge branch...

Merge branch 'feature/ISTWCMS-4824-l26yan-Consolidate-taxonomy-term-creation-functions' into '1.0.x'

ISTWCMS-4824 Use _uw_cfg_common_create_term to create default terms

See merge request !23
parents 0c7a47f5 1a7da421
......@@ -11,43 +11,40 @@ use Drupal\taxonomy\Entity\Term;
* Implements hook_install().
*/
function uw_ct_opportunities_install() {
// Add terms to the vocabulary 'uw_vocab_opportunity_type'.
$opportunity_type_terms = [
'Paid' => 1,
'Volunteer' => 0,
'Research participant' => 0,
];
foreach ($opportunity_type_terms as $opportunity_type_term => $show) {
Term::create([
'name' => $opportunity_type_term,
'vid' => 'uw_vocab_opportunity_type',
'field_uw_opportunity_type_show' => $show,
])->save();
}
// Add terms to the vocabulary 'uw_vocab_opportunity_employment'.
$opportunity_employment_terms = [
'Full time',
'Part time',
];
foreach ($opportunity_employment_terms as $opportunity_employment_term) {
Term::create([
'name' => $opportunity_employment_term,
'vid' => 'uw_vocab_opportunity_employment',
])->save();
}
// Add terms to the vocabulary 'uw_vocab_opportunity_payrate'.
$opportunity_payrate_terms = [
'Honorarium',
'Hourly',
'Salary',
'USG',
// Add terms to vocab uw_vocab_opportunity_type,
// uw_vocab_opportunity_employment and uw_vocab_opportunity_payrate.
$vocabs = [
'uw_vocab_opportunity_type' => [
'Paid' => 1,
'Volunteer' => 0,
'Research participant' => 0,
],
'uw_vocab_opportunity_employment' => [
'Full time',
'Part time',
],
'uw_vocab_opportunity_payrate' => [
'Honorarium',
'Hourly',
'Salary',
'USG',
],
];
foreach ($opportunity_payrate_terms as $opportunity_payrate_term) {
Term::create([
'name' => $opportunity_payrate_term,
'vid' => 'uw_vocab_opportunity_payrate',
])->save();
$weight = 0;
foreach ($vocabs as $vocab => $term_names) {
foreach ($term_names as $term_name => $value) {
// Add a field to terms in uw_vocab_opportunity_type.
if ($vocab == 'uw_vocab_opportunity_type') {
Term::create([
'name' => $term_name,
'vid' => 'uw_vocab_opportunity_type',
'field_uw_opportunity_type_show' => $value,
])->save();
}
else {
_uw_cfg_common_create_term($value, $vocab, $weight, []);
}
}
}
}
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