You are here

public function Role::alterRouteDefinition in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::alterRouteDefinition()
  2. 9 core/modules/user/src/Plugin/views/access/Role.php \Drupal\user\Plugin\views\access\Role::alterRouteDefinition()

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

core/modules/user/src/Plugin/views/access/Role.php, line 78

Class

Role
Access plugin that provides role-based access control.

Namespace

Drupal\user\Plugin\views\access

Code

public function alterRouteDefinition(Route $route) {
  if ($this->options['role']) {
    $route
      ->setRequirement('_role', (string) implode('+', $this->options['role']));
  }
}