You are here

function thunder_riddle_install in Thunder 8.2

Same name and namespace in other branches
  1. 8.5 modules/thunder_riddle/thunder_riddle.install \thunder_riddle_install()
  2. 8.3 modules/thunder_article/modules/thunder_riddle/thunder_riddle.install \thunder_riddle_install()
  3. 8.4 modules/thunder_article/modules/thunder_riddle/thunder_riddle.install \thunder_riddle_install()

Implements hook_install().

Granting permissions for "editor" and "seo" user roles for proper functioning of Riddle entity browser.

File

modules/thunder_article/modules/thunder_riddle/thunder_riddle.install, line 16
Thunder Riddle integration install hooks.

Code

function thunder_riddle_install() {
  $logger = \Drupal::logger('thunder_riddle');

  /** @var \Drupal\user\RoleInterface[] $roles */
  $roles = Role::loadMultiple([
    'editor',
    'seo',
  ]);
  foreach ($roles as $role) {
    $role
      ->grantPermission('access riddle_browser entity browser pages');
    if ($role
      ->save()) {
      $logger
        ->info(t('Permissions to access riddle entity browser granted for "@user_role" user role.', [
        '@user_role' => $role
          ->id(),
      ]));
    }
    else {
      $logger
        ->warning(t('Unable to grant access for riddle entity browser for "@user_role" user role.', [
        '@user_role' => $role
          ->id(),
      ]));
    }
  }
}