You are here

public function Update120::grantUnpublishedContentReviewerAccess in Lightning Workflow 8.2

Same name and namespace in other branches
  1. 8.3 src/Update/Update120.php \Drupal\lightning_workflow\Update\Update120::grantUnpublishedContentReviewerAccess()
  2. 8 src/Update/Update120.php \Drupal\lightning_workflow\Update\Update120::grantUnpublishedContentReviewerAccess()

Grants the reviewer content role permissions to view unpublished content.

@update

Parameters

StyleInterface $io: The I/O style.

File

src/Update/Update120.php, line 61

Class

Update120
Plugin annotation @Update("1.2.0");

Namespace

Drupal\lightning_workflow\Update

Code

public function grantUnpublishedContentReviewerAccess(StyleInterface $io) {
  if (!$this->moduleHandler
    ->moduleExists('lightning_roles')) {
    return;
  }

  /** @var \Drupal\lightning_roles\ContentRoleManager $role_manager */
  $role_manager = $this->container
    ->get('lightning.content_roles');
  $question = (string) $this
    ->t('Do you want to give content reviewers the ability to view unpublished content?');
  if ($io
    ->confirm($question)) {
    $role_manager
      ->grantPermissions('reviewer', [
      'view any unpublished content',
    ]);
  }
  $question = (string) $this
    ->t('Do you want to give content reviewers the ability to view the latest unpublished revisions of content?');
  if ($io
    ->confirm($question)) {
    $role_manager
      ->grantPermissions('reviewer', [
      'view latest version',
    ]);
  }
}