You are here

public function EntityTypeManager::getDefinition in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getDefinition()

Return value

\Drupal\Core\Entity\EntityTypeInterface|null

Overrides DiscoveryCachedTrait::getDefinition

4 calls to EntityTypeManager::getDefinition()
EntityTypeManager::getActiveDefinition in core/lib/Drupal/Core/Entity/EntityTypeManager.php
Gets the active definition for a content entity type.
EntityTypeManager::getHandler in core/lib/Drupal/Core/Entity/EntityTypeManager.php
Returns a handler instance for the given entity type and handler.
EntityTypeManager::getRouteProviders in core/lib/Drupal/Core/Entity/EntityTypeManager.php
Gets all route provider instances.
EntityTypeManager::hasHandler in core/lib/Drupal/Core/Entity/EntityTypeManager.php
Checks whether a certain entity type has a certain handler.

File

core/lib/Drupal/Core/Entity/EntityTypeManager.php, line 135

Class

EntityTypeManager
Manages entity type plugin definitions.

Namespace

Drupal\Core\Entity

Code

public function getDefinition($entity_type_id, $exception_on_invalid = TRUE) {
  if (($entity_type = parent::getDefinition($entity_type_id, FALSE)) && class_exists($entity_type
    ->getClass())) {
    return $entity_type;
  }
  elseif (!$exception_on_invalid) {
    return NULL;
  }
  throw new PluginNotFoundException($entity_type_id, sprintf('The "%s" entity type does not exist.', $entity_type_id));
}