function total_control_install in Total Control Admin Dashboard 3.0.x
Same name and namespace in other branches
- 8.2 total_control.install \total_control_install()
- 7.2 total_control.install \total_control_install()
Implements hook_install().
File
- ./
total_control.install, line 13 - Install, update and uninstall functions for the Total Control module.
Code
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);
}
}
}