public function EntityIsEventCheck::access in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Access/EntityIsEventCheck.php \Drupal\rng\Access\EntityIsEventCheck::access()
- 3.x src/Access/EntityIsEventCheck.php \Drupal\rng\Access\EntityIsEventCheck::access()
Checks that an entity is an event type.
File
- src/
Access/ EntityIsEventCheck.php, line 38
Class
- EntityIsEventCheck
- Checks that an entity is an event type.
Namespace
Drupal\rng\AccessCode
public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
if ($event = $route
->getDefault('event')) {
$event = $route_match
->getParameter($event);
if ($event instanceof EntityInterface) {
$event_type = $this->eventManager
->eventType($event
->getEntityTypeId(), $event
->bundle());
if ($event_type) {
return AccessResult::allowed()
->addCacheableDependency($event)
->addCacheableDependency($event_type);
}
return AccessResult::neutral()
->addCacheableDependency($event);
}
}
return AccessResult::neutral();
}