total_control.install in Total Control Admin Dashboard 8.2
Same filename and directory in other branches
Install, update and uninstall functions for the Total Control module.
File
total_control.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Total Control module.
*/
use Symfony\Component\Yaml\Yaml;
/**
* Implements hook_install().
*/
function total_control_install() {
// If the Comment module was enabled we load the Drupal standard configs.
// 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);
}
}
}
Functions
Name | Description |
---|---|
total_control_install | Implements hook_install(). |