You are here

public function PageManagerController::performPageOperation 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::performPageOperation()

Enables or disables a Page.

Parameters

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

string $op: The operation to perform, usually 'enable' or 'disable'.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect back to the pages list page.

1 string reference to 'PageManagerController::performPageOperation'
page_manager_ui.routing.yml in page_manager_ui/page_manager_ui.routing.yml
page_manager_ui/page_manager_ui.routing.yml

File

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

Class

PageManagerController
Provides route controllers for Page Manager.

Namespace

Drupal\page_manager_ui\Controller

Code

public function performPageOperation(PageInterface $page, $op) {
  $page
    ->{$op}()
    ->save();
  if ($op == 'enable') {
    drupal_set_message($this
      ->t('The %label page has been enabled.', [
      '%label' => $page
        ->label(),
    ]));
  }
  elseif ($op == 'disable') {
    drupal_set_message($this
      ->t('The %label page has been disabled.', [
      '%label' => $page
        ->label(),
    ]));
  }
  return $this
    ->redirect('entity.page.collection');
}