opigno_ilt.install in Opigno Instructor-led Trainings 3.x
Same filename and directory in other branches
Install, update and uninstall functions for the Opigno ILT module.
File
opigno_ilt.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Opigno ILT module.
*/
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\group\Entity\GroupRole;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
/**
* Implements hook_install().
*/
function opigno_ilt_install() {
// Enable new module opigno_cron.
if (!\Drupal::moduleHandler()
->moduleExists('opigno_cron')) {
\Drupal::service('module_installer')
->install([
'opigno_cron',
]);
}
if (\Drupal::isConfigSyncing()) {
return;
}
try {
// Allow users to view ILT entities.
$role = Role::load(RoleInterface::AUTHENTICATED_ID);
$role
->grantPermission('view ilt entities');
$role
->save();
// Allow platform-level student managers to score ILT entities.
$role = Role::load('user_manager');
$role
->grantPermission('score ilt entities');
$role
->save();
// Allow group-level student managers to score ILT entities.
$role = GroupRole::load('learning_path-user_manager');
$role
->grantPermission('score ilt entities');
$role
->save();
} catch (EntityStorageException $e) {
watchdog_exception('opigno_ilt_exception', $e);
}
}
/**
* Update display view.
*/
function opigno_ilt_update_9001() {
$config_path = drupal_get_path('module', 'opigno_ilt') . '/config/install';
$storage = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');
$data = $storage
->read('core.entity_view_display.opigno_calendar_event.ilt_calendar_event.default');
$config_storage
->write('core.entity_view_display.opigno_calendar_event.ilt_calendar_event.default', $data);
}
Functions
Name | Description |
---|---|
opigno_ilt_install | Implements hook_install(). |
opigno_ilt_update_9001 | Update display view. |