This repository was archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_guide.install
More file actions
90 lines (78 loc) · 2.58 KB
/
student_guide.install
File metadata and controls
90 lines (78 loc) · 2.58 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
use Drupal\user\UserInterface;
/**
* @file
* Install, update and uninstall functions for the student guide installation
* profile.
*/
/**
* Implements hook_install().
*
* Performs actions to set up the site for this profile.
*
* @see system_install()
*/
function student_guide_install() {
// Disable the user pictures on nodes.
\Drupal::configFactory()->getEditable('system.theme.global')->set('features.node_user_picture', FALSE)->save(TRUE);
// Allow visitor account creation, but with administrative approval.
\Drupal::configFactory()->getEditable('user.settings')->set('register', UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save(TRUE);
// Ensure the translation fields are created in the database.
// see https://www.drupal.org/node/2599228
\Drupal::service('entity.definition_update_manager')->applyUpdates();
student_guide_create_front_page_text_block();
student_guide_create_front_page_additional_text_block();
}
/**
* Add path aliases (translations) for "/news".
*/
function student_guide_update_8001(&$sandbox) {
$system_path = '/news';
$path_aliases = ['fi' => '/uutiset', 'sv' => '/nyheter'];
foreach ($path_aliases as $langcode => $path_alias) {
\Drupal::service('path.alias_storage')->save($system_path, $path_alias, $langcode);
}
}
/**
* Move english login/logout links to main menu.
* Delete other login/logout links.
*/
function student_guide_update_8002(&$sandbox) {
$links = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadMultiple();
$titles_to_delete = [
'Kirjaudu sisään',
'Kirjaudu ulos',
'Logga in',
'Logga ut',
];
$titles_to_move = ['Login', 'Logout'];
foreach ($links as $link) {
if (in_array($link->getTitle(), $titles_to_delete)) {
$link->delete();
}
if (in_array($link->getTitle(), $titles_to_move)) {
$link->set('menu_name', 'main');
$link->save();
}
}
}
/**
* Create front page additional text block.
*/
function student_guide_update_8003(&$sandbox) {
student_guide_create_front_page_additional_text_block();
}
/**
* Create front page text blocks for Instructions for teaching.
*/
function student_guide_update_8004(&$sandbox) {
student_guide_create_teaching_front_page_text_block();
student_guide_create_teaching_front_page_additional_text_block();
}
/**
* Create degree programme selector description text blocks.
*/
function student_guide_update_8005(&$sandbox) {
student_guide_create_students_degree_programme_selection_description_text_block();
student_guide_create_teaching_degree_programme_selection_description_text_block();
}