You are here

function opigno_ilt_install in Opigno Instructor-led Trainings 3.x

Same name and namespace in other branches
  1. 8 opigno_ilt.install \opigno_ilt_install()

Implements hook_install().

File

./opigno_ilt.install, line 17
Install, update and uninstall functions for the Opigno ILT module.

Code

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);
  }
}