event_platform-1.0.x-dev/event_platform_bofs/event_platform_bofs.install
event_platform_bofs/event_platform_bofs.install
<?php /** * @file * Install, update and uninstall functions for the Event Platform BOFs module. */ use Drupal\user\Entity\Role; /** * Implements hook_install(). */ function event_platform_bofs_install() { // Add permission to view field_r and field_time_slot. foreach (['authenticated'] as $role) { $role_object = Role::load($role); $role_object->grantPermission('create bof content'); $role_object->save(); } // Add permission to view field_r and field_time_slot. foreach (['session_moderator'] as $role) { $role_object = Role::load($role); if (!$role_object) { continue; } $role_object->grantPermission('edit any bof content'); $role_object->grantPermission('view bof revisions'); $role_object->save(); } // If the My Schedule flag is present, include BOFs. $config_factory = \Drupal::configFactory(); $flags = $config_factory->listAll('flag.flag.'); if ($flags && in_array('flag.flag.my_schedule', $flags)) { $flag = $config_factory->getEditable('flag.flag.my_schedule'); if ($flag) { $bundles = $flag->get('bundles'); $bundles[] = 'bof'; $flag->set('bundles', $bundles); $flag->save(TRUE); } } $scheduler = $config_factory->getEditable('event_platform_scheduler.settings'); if ($scheduler) { $types = $scheduler->get('types'); $types['bof'] = 'bof'; $scheduler->set('types', $types); $scheduler->save(TRUE); } \Drupal::service('cache.config')->invalidateAll(); \Drupal::service('cache.render')->invalidateAll(); }