function EntityTypeManager::getDefinition

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getDefinition()
  2. 10 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getDefinition()
  3. 11.x core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getDefinition()

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 142

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));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.