You are here

public function PageManagerController::selectAccessCondition in Page Manager 8

Same name and namespace in other branches
  1. 8.4 page_manager_ui/src/Controller/PageManagerController.php \Drupal\page_manager_ui\Controller\PageManagerController::selectAccessCondition()

Presents a list of access conditions to add to the page entity.

Parameters

\Drupal\page_manager\PageInterface $page: The page entity.

Return value

array The access condition selection page.

File

page_manager_ui/src/Controller/PageManagerController.php, line 246
Contains \Drupal\page_manager_ui\Controller\PageManagerController.

Class

PageManagerController
Provides route controllers for Page Manager.

Namespace

Drupal\page_manager_ui\Controller

Code

public function selectAccessCondition(PageInterface $page) {
  $build = [
    '#theme' => 'links',
    '#links' => [],
  ];
  $available_plugins = $this->conditionManager
    ->getDefinitionsForContexts($page
    ->getContexts());
  foreach ($available_plugins as $access_id => $access_condition) {
    $build['#links'][$access_id] = [
      'title' => $access_condition['label'],
      'url' => Url::fromRoute('page_manager.access_condition_add', [
        'page' => $page
          ->id(),
        'condition_id' => $access_id,
      ]),
      'attributes' => $this
        ->getAjaxAttributes(),
    ];
  }
  return $build;
}