5 * Finalize any extra CMS changes in Drupal.
8 if (!defined('CIVI_SETUP')) {
9 exit("Installation plugins must only be loaded by the installer.\n");
12 \Civi\Setup
::dispatcher()
13 ->addListener('civi.setup.installDatabase', function (\Civi\Setup\Event\InstallDatabaseEvent
$e) {
14 if ($e->getModel()->cms
!== 'Drupal8') {
17 \Civi\Setup
::log()->info(sprintf('[%s] Flush CMS metadata', basename(__FILE__
)));
19 \Drupal
::service('extension.list.module')->reset();
20 \Drupal
::service('module_installer')->install(['civicrm', 'civicrmtheme']);
21 drupal_flush_all_caches();
22 civicrm_install_set_drupal8_perms();
24 }, \Civi\Setup
::PRIORITY_LATE
- 50);
26 function civicrm_install_set_drupal8_perms() {
28 'access all custom data',
29 'access uploaded files',
30 'make online contributions',
34 'register for events',
36 'view event participants',
37 'access CiviMail subscribe/unsubscribe pages',
40 // Adding a permission that has not yet been assigned to a module by
41 // a hook_permission implementation results in a database error.
44 /** @var \Drupal\user\PermissionHandlerInterface $permissionHandler */
45 $permissionHandler = \Drupal
::service('user.permissions');
47 $allPerms = array_keys($permissionHandler->getPermissions());
48 foreach (array_diff($perms, $allPerms) as $perm) {
49 \Drupal
::logger('my_module')->error('Cannot grant the %perm permission because it does not yet exist.', [
53 $perms = array_intersect($perms, $allPerms);
54 user_role_grant_permissions(\Drupal\user\RoleInterface
::AUTHENTICATED_ID
, $perms);
55 user_role_grant_permissions(\Drupal\user\RoleInterface
::ANONYMOUS_ID
, $perms);