W3cubDocs

/Drupal 8

protected function DefaultHtmlRouteProvider::getEntityTypeIdKeyType

protected DefaultHtmlRouteProvider::getEntityTypeIdKeyType(EntityTypeInterface $entity_type)

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.

File

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

Class

DefaultHtmlRouteProvider
Provides HTML routes for entities.

Namespace

Drupal\Core\Entity\Routing

Code

protected function getEntityTypeIdKeyType(EntityTypeInterface $entity_type) {
  if (!$entity_type->isSubclassOf(FieldableEntityInterface::class)) {
    return NULL;
  }

  $field_storage_definitions = $this->entityFieldManager->getFieldStorageDefinitions($entity_type->id());
  return $field_storage_definitions[$entity_type->getKey('id')]->getType();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Routing!DefaultHtmlRouteProvider.php/function/DefaultHtmlRouteProvider::getEntityTypeIdKeyType/8.1.x