public function EventManager::getMeta in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/EventManager.php \Drupal\rng\EventManager::getMeta()
- 3.x src/EventManager.php \Drupal\rng\EventManager::getMeta()
Get the meta instance for an event.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: An event entity.
Return value
\Drupal\rng\EventMetaInterface|NULL An event meta object.
Throws
\Drupal\rng\Exception\InvalidEventException If the $entity is not an event.
Overrides EventManagerInterface::getMeta
File
- src/
EventManager.php, line 45
Class
- EventManager
- Event manager for RNG.
Namespace
Drupal\rngCode
public function getMeta(EntityInterface $entity) {
$entity_type = $entity
->getEntityTypeId();
$id = $entity
->id();
if (!$this
->isEvent($entity)) {
throw new InvalidEventException(sprintf('%s: %s is not an event bundle.', $entity
->getEntityTypeId(), $entity
->bundle()));
}
if (!isset($this->event_meta[$entity_type][$id])) {
$this->event_meta[$entity_type][$id] = EventMeta::createInstance($this->container, $entity);
}
return $this->event_meta[$entity_type][$id];
}