function lightning_media_modules_installed in Lightning Media 8
Same name and namespace in other branches
- 8.4 lightning_media.module \lightning_media_modules_installed()
- 8.2 lightning_media.module \lightning_media_modules_installed()
- 8.3 lightning_media.module \lightning_media_modules_installed()
Implements hook_modules_installed().
1 call to lightning_media_modules_installed()
- lightning_media_install in ./
lightning_media.install - Implements hook_install().
File
- ./
lightning_media.module, line 135 - Core media asset support for Lightning.
Code
function lightning_media_modules_installed(array $modules) {
// Don't do anything during config sync.
if (\Drupal::isConfigSyncing()) {
return;
}
if (in_array('lightning_roles', $modules)) {
\Drupal::service('lightning.content_roles')
->grantPermissions('creator', [
'use text format rich_text',
'access media_browser entity browser pages',
]);
}
if (in_array('lightning_dev', $modules)) {
\Drupal::service('module_installer')
->install([
'image_widget_crop',
'lightning_page',
]);
module_load_install('lightning_media_image');
lightning_media_image_install();
$config = Config::forModule('lightning_media')
->optional();
$config
->getEntity('user_role', 'media_creator')
->save();
$config
->getEntity('user_role', 'media_manager')
->save();
user_role_grant_permissions('media_creator', [
'access content',
'access content overview',
'access image_browser entity browser pages',
'create page content',
'edit own page content',
'use text format rich_text',
'view own unpublished content',
]);
\Drupal::service('theme_installer')
->install([
'bartik',
'seven',
]);
$config_factory = \Drupal::configFactory();
$config_factory
->getEditable('system.theme')
->set('default', 'bartik')
->set('admin', 'seven')
->save();
$config_factory
->getEditable('node.settings')
->set('use_admin_theme', TRUE)
->save();
// Sentence-case the label of the media browser's embed code widget. Yes, not
// doing this can cause tests to fail.
$config_factory
->getEditable('entity_browser.browser.media_browser')
->set('widgets.8b142f33-59d1-47b1-9e3a-4ae85d8376fa.label', 'Create embed')
->save();
$GLOBALS['install_state'] = [];
$view = entity_load('view', 'media');
lightning_media_view_insert($view);
unset($GLOBALS['install_state']);
}
}