Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
24 / 24
100.00% covered (success)
100.00%
1 / 1
CRAP
n/a
0 / 0
open_knowledge_install
100.00% covered (success)
100.00%
24 / 24
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @file
5 * Install, update and uninstall functions for the open knowledge profile.
6 */
7
8/**
9 * Implements hook_install().
10 *
11 * Perform actions to set up the site for this profile.
12 *
13 * @see system_install()
14 */
15function open_knowledge_install() {
16  $entity_type_manager = \Drupal::entityTypeManager();
17  $user_storage = $entity_type_manager->getStorage('user');
18  // Assign user 1 the "administrator" role.
19  /** @var \Drupal\user\Entity\User $user */
20  $user = $user_storage->load(1);
21  $user->addRole('administrator');
22  $user->save();
23
24  $shortcut_storage = $entity_type_manager->getStorage('shortcut');
25  // Populate the default shortcut set.
26  $shortcut = $shortcut_storage->create([
27    'shortcut_set' => 'default',
28    'title' => t('Add content'),
29    'weight' => -20,
30    'link' => ['uri' => 'internal:/node/add'],
31  ]);
32  $shortcut->save();
33
34  $shortcut = $shortcut_storage->create([
35    'shortcut_set' => 'default',
36    'title' => t('All content'),
37    'weight' => -19,
38    'link' => ['uri' => 'internal:/admin/content'],
39  ]);
40  $shortcut->save();
41
42  $workflow = \Drupal::entityTypeManager()->getStorage('workflow')->load('knowledge');
43  $type_settings = $workflow->get('type_settings');
44  $type_settings['entity_types']['node'] = ['article'];
45  $workflow->set('type_settings', $type_settings)->save();
46}