You are here

public function ViewsAccessCallback::alterRouteDefinition in Views Access Callback 8

Allows access plugins to alter the route definition of a view.

Likely the access plugin will add new requirements, so its custom access checker can be applied.

Parameters

\Symfony\Component\Routing\Route $route: The route to change.

Overrides AccessPluginBase::alterRouteDefinition

File

src/Plugin/views/access/ViewsAccessCallback.php, line 77

Class

ViewsAccessCallback
Access plugin that provides permission-based access control.

Namespace

Drupal\views_access_callback\Plugin\views\access

Code

public function alterRouteDefinition(Route $route) {
  $bool = views_access_callback_access_callback($this->view->storage
    ->id(), $this->view->current_display, $this->options['views_access_callback']) ? 'TRUE' : 'FALSE';
  $route
    ->setRequirement('_access', $bool);
}