protected function RngEventRouteContext::getEventEntitiesInRoute in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/ContextProvider/RngEventRouteContext.php \Drupal\rng\ContextProvider\RngEventRouteContext::getEventEntitiesInRoute()
- 3.x src/ContextProvider/RngEventRouteContext.php \Drupal\rng\ContextProvider\RngEventRouteContext::getEventEntitiesInRoute()
Get all event entities from the current route.
Return value
\Drupal\Core\Entity\EntityInterface[] An array of event entities in route.
1 call to RngEventRouteContext::getEventEntitiesInRoute()
- RngEventRouteContext::getEventInRoute in src/
ContextProvider/ RngEventRouteContext.php - Determine the event in the current route.
File
- src/
ContextProvider/ RngEventRouteContext.php, line 117
Class
- RngEventRouteContext
- Get the current RNG event from the route.
Namespace
Drupal\rng\ContextProviderCode
protected function getEventEntitiesInRoute() {
$events = [];
if (($route = $this->routeMatch
->getRouteObject()) && ($parameters = $route
->getOption('parameters'))) {
foreach ($parameters as $parameter) {
if (isset($parameter['type']) && strpos($parameter['type'], 'entity:') !== FALSE) {
$entity_type_id = substr($parameter['type'], strlen('entity:'));
$entity = $this->routeMatch
->getParameter($entity_type_id);
if ($entity instanceof EntityInterface && $this->eventManager
->isEvent($entity)) {
$events[] = $entity;
}
}
}
}
return $events;
}