class EntityIsEventCheck in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Access/EntityIsEventCheck.php \Drupal\rng\Access\EntityIsEventCheck
- 3.x src/Access/EntityIsEventCheck.php \Drupal\rng\Access\EntityIsEventCheck
Checks that an entity is an event type.
Hierarchy
- class \Drupal\rng\Access\EntityIsEventCheck implements AccessInterface
Expanded class hierarchy of EntityIsEventCheck
1 string reference to 'EntityIsEventCheck'
1 service uses EntityIsEventCheck
File
- src/
Access/ EntityIsEventCheck.php, line 16
Namespace
Drupal\rng\AccessView source
class EntityIsEventCheck implements AccessInterface {
/**
* The RNG event manager.
*
* @var \Drupal\rng\EventManagerInterface
*/
protected $eventManager;
/**
* Constructs a new EntityIsEventCheck object.
*
* @param \Drupal\rng\EventManagerInterface $event_manager
* The RNG event manager.
*/
public function __construct(EventManagerInterface $event_manager) {
$this->eventManager = $event_manager;
}
/**
* Checks that an entity is an event type.
*/
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();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityIsEventCheck:: |
protected | property | The RNG event manager. | |
EntityIsEventCheck:: |
public | function | Checks that an entity is an event type. | |
EntityIsEventCheck:: |
public | function | Constructs a new EntityIsEventCheck object. |