You are here

final class Update120 in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8 src/Update/Update120.php \Drupal\lightning_workflow\Update\Update120
  2. 8.2 src/Update/Update120.php \Drupal\lightning_workflow\Update\Update120

Contains optional updates targeting Lightning Workflow 1.2.0.

Plugin annotation

@Update("1.2.0");

Hierarchy

  • class \Drupal\lightning_workflow\Update\Update120 implements \Symfony\Component\DependencyInjection\ContainerAwareInterface, ContainerInjectionInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait

Expanded class hierarchy of Update120

File

src/Update/Update120.php, line 19

Namespace

Drupal\lightning_workflow\Update
View source
final class Update120 implements ContainerInjectionInterface, ContainerAwareInterface {
  use ContainerAwareTrait, StringTranslationTrait;

  /**
   * The module handler service.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Update100 constructor.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler service.
   * @param \Drupal\Core\StringTranslation\TranslationInterface $translation
   *   (optional) The string translation service.
   */
  public function __construct(ModuleHandlerInterface $module_handler, TranslationInterface $translation = NULL) {
    $this->moduleHandler = $module_handler;
    if ($translation) {
      $this
        ->setStringTranslation($translation);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('module_handler'), $container
      ->get('string_translation'));
  }

  /**
   * Grants the reviewer content role permissions to view unpublished content.
   *
   * @param \Symfony\Component\Console\Style\StyleInterface $io
   *   The I/O style.
   *
   * @update
   */
  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',
      ]);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Update120::$moduleHandler protected property The module handler service.
Update120::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
Update120::grantUnpublishedContentReviewerAccess public function Grants the reviewer content role permissions to view unpublished content.
Update120::__construct public function Update100 constructor.