You are here

public function Kanban::__construct in Content Planner 8

Constructor for the Kanban class.

Parameters

\Drupal\Core\Session\AccountInterface $current_user: The current user service.

\Drupal\content_kanban\KanbanService $kanban_service: The Kanban service.

\Drupal\workflows\Entity\Workflow $workflow: The workflow service.

Throws

\Exception

File

modules/content_kanban/src/Component/Kanban.php, line 86

Class

Kanban
The main Kanban class.

Namespace

Drupal\content_kanban\Component

Code

public function __construct(AccountInterface $current_user, KanbanService $kanban_service, Workflow $workflow) {
  if (!self::isValidContentModerationWorkflow($workflow)) {
    throw new \Exception('The given workflow is no valid Content Moderation Workflow');
  }

  // Store request object.
  $this->request = \Drupal::request();

  // Store current user.
  $this->currentUser = $current_user;

  // Store Kanban service.
  $this->kanbanService = $kanban_service;

  // Store Workflow.
  $this->workflow = $workflow;

  // Store Workflow ID.
  $this->workflowID = $workflow
    ->get('id');

  // Store Type settings.
  $this->typeSettings = $workflow
    ->get('type_settings');

  // Store Entity types this workflow applies to.
  $this->entityTypes = $this->typeSettings['entity_types'];

  // Store states.
  $this->states = $this
    ->sortStates($this->typeSettings['states']);
}