forked from galaniprojects/liveblog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathliveblog.install
39 lines (37 loc) · 1.05 KB
/
liveblog.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* @file
* Install file of the liveblog module.
*/
/**
* Implements hook_install().
*
* Add default highlights.
*/
function liveblog_install() {
$parent = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->create([
'name' => 'General',
'vid' => \Drupal\liveblog\Entity\LiveblogPost::LIVEBLOG_POSTS_HIGHLIGHTS_VID,
]);
$parent->save();
$term_names = [
'Breaking news',
'First valid information',
'Official statement',
'Expert analysis',
'New important fact',
'Summary of last hours',
'Unexpected incident',
'Situation under control',
];
foreach ($term_names as $term_name) {
/* @var $term \Drupal\taxonomy\Entity\Term */
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->create([
'name' => $term_name,
'vid' => \Drupal\liveblog\Entity\LiveblogPost::LIVEBLOG_POSTS_HIGHLIGHTS_VID,
]);
$term->parent = [$parent->id()];
$term->save();
}
drupal_set_message(t('@count default highlight terms were created.', ['@count' => count($term_names) + 1]));
}