public function EntityOperation::alterRouteDefinition in Views Entity Operation Access 8
Same name and namespace in other branches
- 2.x src/Plugin/views/access/EntityOperation.php \Drupal\veoa\Plugin\views\access\EntityOperation::alterRouteDefinition()
This method is called when the view is saved.
Overrides AccessPluginBase::alterRouteDefinition
File
- src/
Plugin/ views/ access/ EntityOperation.php, line 82
Class
- EntityOperation
- Access plugin checking if the current user can operate on an entity.
Namespace
Drupal\veoa\Plugin\views\accessCode
public function alterRouteDefinition(Route $route) {
if ($this
->isValidConfig()) {
$parameter = $this->options['parameter'];
$entity_type = $this->options['entity_type'];
$operation = $this->options['operation'];
$options = $route
->getOptions();
$options['parameters'][$parameter]['type'] = 'entity:' . $entity_type;
$route
->setRequirement('_entity_access', $entity_type . '.' . $operation)
->setOptions($options);
}
}