-
Notifications
You must be signed in to change notification settings - Fork 0
/
total_control.install
58 lines (48 loc) · 2.08 KB
/
total_control.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* @file
* Install, update and uninstall functions for the Total Control module.
*/
use Symfony\Component\Yaml\Yaml;
/**
* Implements hook_install().
*/
function total_control_install() {
// Load the Drupal standard configs,
// If the Comment module was enabled.
// And the Total Control Comments view.
if (\Drupal::moduleHandler()->moduleExists('comment')) {
$comment_managed_optional_path = Drupal::service('module_handler')->getModule('total_control')->getPath() . '/config/managed/comment';
// Drupal core standard profile configs for comment.
$comment_managed_optional_configs = [
'comment.type.comment',
'field.field.comment.comment.comment_body',
'rdf.mapping.comment.comment',
'core.entity_form_display.comment.comment.default',
'core.entity_view_display.comment.comment.default',
'field.storage.node.comment',
'views.view.control_comments',
];
foreach ($comment_managed_optional_configs as $config_name) {
$config_path = $comment_managed_optional_path . '/' . $config_name . '.yml';
$config_content = file_get_contents($config_path);
$config_data = (array) Yaml::parse($config_content);
$config_factory = \Drupal::configFactory()->getEditable($config_name);
$config_factory->setData($config_data)->save(TRUE);
}
}
// If the Taxonomy module was enabled then we add the Total Control Term view.
if (\Drupal::moduleHandler()->moduleExists('taxonomy')) {
$taxonomy_managed_optional_path = Drupal::service('module_handler')->getModule('total_control')->getPath() . '/config/managed/taxonomy';
$taxonomy_managed_optional_configs = [
'views.view.control_terms',
];
foreach ($taxonomy_managed_optional_configs as $config_name) {
$config_path = $taxonomy_managed_optional_path . '/' . $config_name . '.yml';
$config_content = file_get_contents($config_path);
$config_data = (array) Yaml::parse($config_content);
$config_factory = \Drupal::configFactory()->getEditable($config_name);
$config_factory->setData($config_data)->save(TRUE);
}
}
}