function thunder_modules_installed in Thunder 8.2
Same name and namespace in other branches
- 8.5 thunder.profile \thunder_modules_installed()
- 8.3 thunder.profile \thunder_modules_installed()
- 8.4 thunder.profile \thunder_modules_installed()
- 6.2.x thunder.profile \thunder_modules_installed()
- 6.0.x thunder.profile \thunder_modules_installed()
- 6.1.x thunder.profile \thunder_modules_installed()
Implements hook_modules_installed().
File
- ./
thunder.profile, line 297 - Enables modules and site configuration for a thunder site installation.
Code
function thunder_modules_installed($modules) {
if (_thunder_is_enabling_module() && _thunder_check_triggering_modules($modules, [
'content_moderation',
'config_update',
])) {
if (!Role::load('restricted_editor')) {
/** @var Drupal\config_update\ConfigRevertInterface $configReverter */
$configReverter = \Drupal::service('config_update.config_update');
$configReverter
->import('user_role', 'restricted_editor');
}
// Granting permissions only for "editor" and "seo" user roles.
$roles = Role::loadMultiple([
'editor',
'seo',
]);
foreach ($roles as $role) {
try {
$role
->grantPermission('use editorial transition create_new_draft');
$role
->grantPermission('use editorial transition publish');
$role
->grantPermission('use editorial transition unpublish');
$role
->grantPermission('use editorial transition unpublished_draft');
$role
->grantPermission('use editorial transition unpublished_published');
$role
->grantPermission('view any unpublished content');
$role
->grantPermission('view latest version');
$role
->save();
} catch (EntityStorageException $storageException) {
}
}
}
if (_thunder_is_enabling_module() && _thunder_check_triggering_modules($modules, [
'content_moderation',
'scheduler',
])) {
\Drupal::service('module_installer')
->install([
'scheduler_content_moderation_integration',
]);
}
// When enabling password policy, enabled required sub modules.
if (_thunder_is_enabling_module() && _thunder_check_triggering_modules($modules, [
'password_policy',
])) {
\Drupal::service('module_installer')
->install([
'password_policy_length',
]);
\Drupal::service('module_installer')
->install([
'password_policy_history',
]);
\Drupal::service('module_installer')
->install([
'password_policy_character_types',
]);
\Drupal::service('messenger')
->addStatus(t('The Password Character Length, Password Policy History and Password Character Types modules have been additionally enabled, they are required by the default policy configuration.'));
}
// Move fields into form display.
if (_thunder_check_triggering_modules($modules, [
'ivw_integration',
])) {
$fieldWidget = 'ivw_integration_widget';
// Attach field if channel vocabulary and article node type is
// present in the distribution.
try {
entity_get_form_display('node', 'article', 'default')
->setComponent('field_ivw', [
'type' => $fieldWidget,
])
->save();
} catch (Exception $e) {
\Drupal::logger('thunder')
->info(t('Could not add ivw field to article node: "@message"', [
'@message' => $e
->getMessage(),
]));
}
try {
entity_get_form_display('taxonomy_term', 'channel', 'default')
->setComponent('field_ivw', [
'type' => $fieldWidget,
])
->save();
} catch (Exception $e) {
\Drupal::logger('thunder')
->info(t('Could not add ivw field to channel taxonomy: "@message"', [
'@message' => $e
->getMessage(),
]));
}
}
// Enable riddle paragraph in field_paragraphs.
if (_thunder_check_triggering_modules($modules, [
'thunder_riddle',
])) {
/** @var \Drupal\field\Entity\FieldConfig $field */
$field = \Drupal::entityTypeManager()
->getStorage('field_config')
->load('node.article.field_paragraphs');
$settings = $field
->getSetting('handler_settings');
$settings['target_bundles']['riddle'] = 'riddle';
$settings['target_bundles_drag_drop']['riddle'] = [
'enabled' => TRUE,
'weight' => 10,
];
$field
->setSetting('handler_settings', $settings);
$field
->save();
}
}