function DefaultHtmlRouteProvider::getEntityTypeIdKeyType

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getEntityTypeIdKeyType()
  2. 10 core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getEntityTypeIdKeyType()
  3. 11.x core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getEntityTypeIdKeyType()

Gets the type of the ID key for a given entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: An entity type.

Return value

string|null The type of the ID key for a given entity type, or NULL if the entity type does not support fields.

5 calls to DefaultHtmlRouteProvider::getEntityTypeIdKeyType()
DefaultHtmlRouteProvider::getAddFormRoute in core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php
Gets the add-form route.
DefaultHtmlRouteProvider::getCanonicalRoute in core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php
Gets the canonical route.
DefaultHtmlRouteProvider::getDeleteFormRoute in core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php
Gets the delete-form route.
DefaultHtmlRouteProvider::getEditFormRoute in core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php
Gets the edit-form route.
TestDefaultHtmlRouteProvider::getEntityTypeIdKeyType in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
Gets the type of the ID key for a given entity type.
1 method overrides DefaultHtmlRouteProvider::getEntityTypeIdKeyType()
TestDefaultHtmlRouteProvider::getEntityTypeIdKeyType in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
Gets the type of the ID key for a given entity type.

File

core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php, line 349

Class

DefaultHtmlRouteProvider
Provides HTML routes for entities.

Namespace

Drupal\Core\Entity\Routing

Code

protected function getEntityTypeIdKeyType(EntityTypeInterface $entity_type) {
    if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) {
        return NULL;
    }
    $field_storage_definitions = $this->entityFieldManager
        ->getFieldStorageDefinitions($entity_type->id());
    return $field_storage_definitions[$entity_type->getKey('id')]
        ->getType();
}

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