You are here

public function KanbanController::showKanbans in Content Planner 8

Show Kanbans.

Return value

array A renderable array with the Kanbans.

Throws

\Exception

1 string reference to 'KanbanController::showKanbans'
content_kanban.routing.yml in modules/content_kanban/content_kanban.routing.yml
modules/content_kanban/content_kanban.routing.yml

File

modules/content_kanban/src/Controller/KanbanController.php, line 86

Class

KanbanController
Class KanbanController.

Namespace

Drupal\content_kanban\Controller

Code

public function showKanbans() {
  $build = [];
  $workflows = Workflow::loadMultiple();
  if (!$workflows) {
    $this
      ->messenger()
      ->addMessage($this
      ->t('There are no Workflows configured yet.'), 'error');
    return [];
  }
  foreach ($workflows as $workflow) {
    if (Kanban::isValidContentModerationWorkflow($workflow)) {
      $kanban = new Kanban($this->currentUser, $this->kanbanService, $workflow);
      $build[] = $kanban
        ->build();
    }
  }

  // If there are no Kanbans, display a message.
  if (!$build) {
    $link = Url::fromRoute('entity.workflow.collection')
      ->toString();
    $message = $this
      ->t('To use Content Kanban, you need to have a valid Content Moderation workflow with at least one Entity Type configured. Please go to the <a href="@link">Workflow</a> configuration.', [
      '@link' => $link,
    ]);
    $this
      ->messenger()
      ->addMessage($message, 'error');
  }
  return $build;
}