You are here

function thunder_translation_install in Thunder 8.5

Same name and namespace in other branches
  1. 6.2.x modules/thunder_translation/thunder_translation.install \thunder_translation_install()
  2. 6.0.x modules/thunder_translation/thunder_translation.install \thunder_translation_install()
  3. 6.1.x modules/thunder_translation/thunder_translation.install \thunder_translation_install()

Implements hook_install().

File

modules/thunder_translation/thunder_translation.install, line 14
Thunder Translation install hooks.

Code

function thunder_translation_install() {

  /** @var \Drupal\user\Entity\Role[] $roles */
  $roles = Role::loadMultiple([
    'editor',
    'seo',
    'restricted_editor',
  ]);
  foreach ($roles as $role) {
    try {
      $role
        ->grantPermission('create content translations');
      $role
        ->grantPermission('update content translations');
      $role
        ->grantPermission('translate any entity');
      if (in_array($role
        ->id(), [
        'editor',
        'seo',
      ])) {
        $role
          ->grantPermission('delete content translations');
      }
      $role
        ->save();
    } catch (EntityStorageException $storageException) {
    }
  }
}