You are here

function thunder_workflow_install in Thunder 8.5

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

Implements hook_install().

File

modules/thunder_workflow/thunder_workflow.install, line 14
The install file.

Code

function thunder_workflow_install() {
  if (!Role::load('restricted_editor')) {

    /** @var Drupal\config_update\ConfigRevertInterface $configReverter */
    $configReverter = \Drupal::service('config_update.config_update');
    $configReverter
      ->import('user_role', 'restricted_editor');
  }

  // Granting permissions only for "editor" and "seo" user roles.
  $roles = Role::loadMultiple([
    'editor',
    'seo',
  ]);
  foreach ($roles as $role) {
    try {
      $role
        ->grantPermission('use editorial transition create_new_draft');
      $role
        ->grantPermission('use editorial transition publish');
      $role
        ->grantPermission('use editorial transition unpublish');
      $role
        ->grantPermission('use editorial transition unpublished_draft');
      $role
        ->grantPermission('use editorial transition unpublished_published');
      $role
        ->grantPermission('view any unpublished content');
      $role
        ->grantPermission('view latest version');
      $role
        ->save();
    } catch (EntityStorageException $storageException) {
    }
  }
}