protected function addFormRoute(EntityTypeInterface $entity_type) { $route = new Route('entity.' . $entity_type->id() . '.add-form'); $route->setDefault('_controller', '\\Drupal\\content_entity_base\\Entity\\Controller\\EntityBaseController::addForm'); $route->setDefault('_title_callback', '\\Drupal\\content_entity_base\\Entity\\Controller\\EntityBaseController::getAddFormTitle'); $route->setDefault('entity_type', $entity_type->id()); $route->setRequirement('_entity_create_access', $entity_type->id()); return $route; }
protected function revisionDeleteRoute(EntityTypeInterface $entity_type) { $route = new Route($entity_type->getLinkTemplate('revision-delete')); $route->setDefault('_form', 'Drupal\\content_entity_base\\Entity\\Form\\EntityRevisionDeleteForm'); $route->setDefault('_title', 'Delete earlier revision'); $route->setRequirement('_entity_access_revision', $entity_type->id() . '.delete'); $route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()], $entity_type->id() . '_revision' => ['type' => 'entity_revision:' . $entity_type->id()]]); return $route; }
/** * Returns the add form route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function addFormRoute(EntityTypeInterface $entity_type) { if ($entity_type->hasLinkTemplate('add-form')) { $route = new Route($entity_type->getLinkTemplate('add-form')); $route->setDefault('_controller', '\\Drupal\\entity\\Controller\\EntityCreateController::addForm'); $route->setDefault('_title_callback', '\\Drupal\\entity\\Controller\\EntityCreateController::addFormTitle'); $route->setDefault('entity_type_id', $entity_type->id()); $route->setRequirement('_entity_create_access', $entity_type->id()); return $route; } }
/** * Gets the entity revision view route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getRevisionViewRoute(EntityTypeInterface $entity_type) { if ($entity_type->hasLinkTemplate('revision')) { $entity_type_id = $entity_type->id(); $route = new Route($entity_type->getLinkTemplate('revision')); $route->addDefaults(['_controller' => '\\Drupal\\entity\\Controller\\RevisionController::view', '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title']); $route->addRequirements(['_entity_access_revision' => "{$entity_type_id}.view"]); $route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()], $entity_type->id() . '_revision' => ['type' => 'entity_revision:' . $entity_type->id()]]); return $route; } }
/** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $container->get('entity.manager'), $container->get('module_handler'), $entity_type->id() ); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { /** @var \Drupal\entity_clone\EntityClone\EntityCloneInterface $entity_clone_handler */ $entity_clone_handler = $this->entityTypeManager->getHandler($this->entityTypeDefinition->id(), 'entity_clone'); if ($this->entityTypeManager->hasHandler($this->entityTypeDefinition->id(), 'entity_clone_form')) { $entity_clone_form_handler = $this->entityTypeManager->getHandler($this->entityTypeDefinition->id(), 'entity_clone_form'); } $properties = []; if (isset($entity_clone_form_handler) && $entity_clone_form_handler) { $properties = $entity_clone_form_handler->getNewValues($form_state); } $cloned_entity = $entity_clone_handler->cloneEntity($this->entity, $this->entity->createDuplicate(), $properties); drupal_set_message($this->stringTranslationManager->translate('The entity <em>@entity (@entity_id)</em> of type <em>@type</em> was cloned', [ '@entity' => $this->entity->label(), '@entity_id' => $this->entity->id(), '@type' => $this->entity->getEntityTypeId(), ])); if ($cloned_entity && $cloned_entity->hasLinkTemplate('canonical')) { $form_state->setRedirect($cloned_entity->toUrl() ->getRouteName(), $cloned_entity->toUrl()->getRouteParameters()); } $form_state->setRedirect('<front>'); }
/** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('scheduled_updates.update_utils') ); }
/** * Constructs a new EntityViewBuilder. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type definition. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) { $this->entityTypeId = $entity_type->id(); $this->entityType = $entity_type; $this->entityManager = $entity_manager; $this->languageManager = $language_manager; }
/** * Build the route for the actual download path. */ protected function getDownloadRoute(EntityTypeInterface $entity_type) { $entity_type_id = $entity_type->id(); $route = new Route("/rdf-export/{$entity_type_id}/{{$entity_type_id}}/{export_format}"); $route->addDefaults(['_controller' => '\\Drupal\\rdf_export\\Controller\\RdfExportController::download', '_title' => 'RDF Export'])->addRequirements(['_permission' => 'export rdf metadata'])->setOption('entity_type_id', $entity_type_id)->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]); return $route; }
/** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('date.formatter') ); }
/** * {@inheritdoc} */ public function getViewsData() { $data = []; // @todo In theory we should use the data table as base table, as this would // save one pointless join (and one more for every relationship). // @see https://drupal.org/node/2337509 $base_table = $this->entityType->getBaseTable(); $base_field = $this->entityType->getKey('id'); $data_table = $this->entityType->getDataTable(); $revision_table = $this->entityType->getRevisionTable(); $revision_data_table = $this->entityType->getRevisionDataTable(); $revision_field = $this->entityType->getKey('revision'); // Setup base information of the views data. $data[$base_table]['table']['entity type'] = $this->entityType->id(); $data[$base_table]['table']['group'] = $this->entityType->getLabel(); $data[$base_table]['table']['base'] = ['field' => $base_field, 'title' => $this->entityType->getLabel()]; if ($label_key = $this->entityType->getKey('label')) { if ($data_table) { $data[$base_table]['table']['base']['defaults'] = array('field' => $label_key, 'table' => $data_table); } else { $data[$base_table]['table']['base']['defaults'] = array('field' => $label_key); } } // Setup relations to the revisions/property data. if ($data_table) { $data[$data_table]['table']['join'][$base_table] = ['left_field' => $base_field, 'field' => $base_field, 'type' => 'INNER']; $data[$data_table]['table']['entity type'] = $this->entityType->id(); $data[$data_table]['table']['group'] = $this->entityType->getLabel(); } if ($revision_table) { $data[$revision_table]['table']['entity type'] = $this->entityType->id(); $data[$revision_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]); $data[$revision_table]['table']['base'] = array('field' => $revision_field, 'title' => $this->t('@entity_type revisions', array('@entity_type' => $this->entityType->getLabel()))); // Join the revision table to the base table. $data[$revision_table]['table']['join'][$base_table] = array('left_field' => $revision_field, 'field' => $revision_field, 'type' => 'INNER'); if ($revision_data_table) { $data[$revision_data_table]['table']['entity type'] = $this->entityType->id(); $data[$revision_data_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]); $data[$revision_data_table]['table']['join'][$revision_table] = array('left_field' => $revision_field, 'field' => $revision_field, 'type' => 'INNER'); } } // Load all typed data definitions of all fields. This should cover each of // the entity base, revision, data tables. $field_definitions = $this->entityManager->getBaseFieldDefinitions($this->entityType->id()); if ($table_mapping = $this->storage->getTableMapping()) { // Iterate over each table we have so far and collect field data for each. // Based on whether the field is in the field_definitions provided by the // entity manager. // @todo We should better just rely on information coming from the entity // storage. // @todo https://drupal.org/node/2337511 foreach ($table_mapping->getTableNames() as $table) { foreach ($table_mapping->getFieldNames($table) as $field_name) { $this->mapFieldDefinition($table, $field_name, $field_definitions[$field_name], $table_mapping, $data[$table]); } } } return $data; }
/** * Constructs an EntityStorageBase instance. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type definition. */ public function __construct(EntityTypeInterface $entity_type) { $this->entityTypeId = $entity_type->id(); $this->entityType = $entity_type; $this->idKey = $this->entityType->getKey('id'); $this->uuidKey = $this->entityType->getKey('uuid'); $this->entityClass = $this->entityType->getClass(); }
/** * Constructs a new EntityViewBuilder. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type definition. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager service. * @param \Drupal\panelizer\Plugin\PanelizerEntityManager $panelizer_manager * The Panelizer entity manager. * @param \Drupal\Panels\PanelsDisplayManagerInterface $panels_manager * The Panels display manager. */ public function __construct(EntityTypeInterface $entity_type, EntityTypeManagerInterface $entity_type_manager, PanelizerEntityManager $panelizer_manager, PanelsDisplayManagerInterface $panels_manager) { $this->entityTypeId = $entity_type->id(); $this->entityType = $entity_type; $this->entityTypeManager = $entity_type_manager; $this->panelizerManager = $panelizer_manager; $this->panelsManager = $panels_manager; }
/** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('url_generator'), $container->get('string_translation') ); }
/** * {@inheritdoc} */ public function evaluate() { if (empty($this->configuration['bundles']) && !$this->isNegated()) { return TRUE; } /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->getContextValue($this->bundleOf->id()); return !empty($this->configuration['bundles'][$entity->bundle()]); }
/** * Sets up the storage accessed via the entity type manager in the form. * * @return \Prophecy\Prophecy\ObjectProphecy * The storage prophecy. */ protected function setUpStorage() { $storage = $this->prophesize(EntityStorageInterface::class); $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class); $entity_type_manager->getDefinition($this->entityType->id())->willReturn($this->entityType); $entity_type_manager->getStorage($this->entityType->id())->willReturn($storage->reveal()); $this->entityForm->setEntityTypeManager($entity_type_manager->reveal()); return $storage; }
/** * Gets the moderation-form route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getModerationFormRoute(EntityTypeInterface $entity_type) { if ($entity_type->hasLinkTemplate('moderation-form') && $entity_type->getFormClass('moderation')) { $entity_type_id = $entity_type->id(); $route = new Route($entity_type->getLinkTemplate('moderation-form')); $route->setDefaults(['_entity_form' => "{$entity_type_id}.moderation", '_title' => 'Moderation'])->setRequirement('_permission', 'administer moderation states')->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]); return $route; } }
/** * Gets the devel render route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getDevelRenderRoute(EntityTypeInterface $entity_type) { if ($devel_render = $entity_type->getLinkTemplate('devel-render')) { $entity_type_id = $entity_type->id(); $route = new Route($devel_render); $route->addDefaults(['_controller' => '\\Drupal\\devel\\Controller\\DevelController::entityRender', '_title' => 'Devel Render'])->addRequirements(['_permission' => 'access devel information'])->setOption('_admin_route', TRUE)->setOption('_devel_entity_type_id', $entity_type_id)->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]); return $route; } }
/** * Initializes an instance of the content translation controller. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The info array of the given entity type. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\content_translation\ContentTranslationManagerInterface $manager * The content translation manager service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. */ public function __construct(EntityTypeInterface $entity_type, LanguageManagerInterface $language_manager, ContentTranslationManagerInterface $manager, EntityManagerInterface $entity_manager, AccountInterface $current_user) { $this->entityTypeId = $entity_type->id(); $this->entityType = $entity_type; $this->languageManager = $language_manager; $this->manager = $manager; $this->currentUser = $current_user; $this->fieldStorageDefinitions = $entity_manager->getLastInstalledFieldStorageDefinitions($this->entityTypeId); }
/** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('theme.manager'), $container->get('form_builder'), $container->get('entity.manager')->getStorage('block_visibility_group'), $container->get('state') ); }
/** * Gets the devel load route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getRdfGraphRoute(EntityTypeInterface $entity_type, $graph_definition) { if ($rdf_draft = $entity_type->getLinkTemplate('rdf-draft-' . $graph_definition['name'])) { $entity_type_id = $entity_type->id(); $route = new Route($rdf_draft); $route->addDefaults(['_controller' => '\\Drupal\\rdf_draft\\Controller\\RdfController::view', '_title' => (string) t('View @title', ['@title' => (string) $graph_definition['title']])])->addRequirements(['_access_rdf_graph' => 'TRUE'])->setOption('entity_type_id', $entity_type_id)->setOption('graph_name', $graph_definition['name'])->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]); return $route; } return NULL; }
/** * Adds base field info to an entity type. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * Entity type for adding base fields to. * * @return \Drupal\Core\Field\BaseFieldDefinition[] * New fields added by moderation state. */ public function entityBaseFieldInfo(EntityTypeInterface $entity_type) { if ($entity_type->isRevisionable()) { $fields = []; // @todo write a test for this. $fields['moderation_state'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Moderation state'))->setDescription(t('The moderation state of this piece of content.'))->setSetting('target_type', 'moderation_state')->setTargetEntityTypeId($entity_type->id())->setRevisionable(TRUE)->setDisplayOptions('view', ['label' => 'hidden', 'type' => 'string', 'weight' => -5])->setDisplayOptions('form', ['type' => 'moderation_state_default', 'weight' => 5, 'settings' => []])->addConstraint('ModerationState', [])->setDisplayConfigurable('form', FALSE)->setDisplayConfigurable('view', TRUE); return $fields; } return []; }
/** * Returns the delete multiple form route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function deleteMultipleFormRoute(EntityTypeInterface $entity_type) { if ($entity_type->hasLinkTemplate('delete-multiple-form')) { $route = new Route($entity_type->getLinkTemplate('delete-multiple-form')); $route->setDefault('_form', '\\Drupal\\entity\\Form\\DeleteMultiple'); $route->setDefault('entity_type_id', $entity_type->id()); $route->setRequirement('_permission', $entity_type->getAdminPermission()); return $route; } }
/** * Gets the entity_clone route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getEntityCloneRoute(EntityTypeInterface $entity_type) { if ($clone_form = $entity_type->getLinkTemplate('clone-form')) { $entity_type_id = $entity_type->id(); $route = new Route($clone_form); $route ->addDefaults([ '_form' => '\Drupal\entity_clone\Form\EntityCloneForm', '_title' => 'Clone ' . $entity_type->getLabel(), ]) ->addRequirements([ '_permission' => 'clone ' . $entity_type->id() . ' entity', ]) ->setOption('_entity_clone_entity_type_id', $entity_type_id) ->setOption('_admin_route', TRUE) ->setOption('parameters', [ $entity_type_id => ['type' => 'entity:' . $entity_type_id], ]); return $route; } }
/** * Gets the add-form route. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */ protected function getAddFormRoute(EntityTypeInterface $entity_type) { if ($entity_type->hasLinkTemplate('add-form')) { $entity_type_id = $entity_type->id(); $route = new Route($entity_type->getLinkTemplate('add-form')); // Use the add form handler, if available, otherwise default. $operation = 'default'; if ($entity_type->getFormClass('add')) { $operation = 'add'; } $route->setDefaults(['_entity_form' => "{$entity_type_id}.{$operation}", '_title' => "Add {$entity_type->getLabel()}"])->setRequirement('_entity_create_access', $entity_type_id)->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]])->setOption('_admin_route', TRUE); return $route; } }
/** * Sets the entity links in case corresponding link templates exist. * * @param array $data * The views data of the base table. */ protected function addEntityLinks(array &$data) { $entity_type_id = $this->entityType->id(); $t_arguments = ['@entity_type_label' => $this->entityType->getLabel()]; if ($this->entityType->hasLinkTemplate('canonical')) { $data['view_' . $entity_type_id] = ['field' => ['title' => $this->t('Link to @entity_type_label', $t_arguments), 'help' => $this->t('Provide a view link to the @entity_type_label.', $t_arguments), 'id' => 'entity_link']]; } if ($this->entityType->hasLinkTemplate('edit-form')) { $data['edit_' . $entity_type_id] = ['field' => ['title' => $this->t('Link to edit @entity_type_label', $t_arguments), 'help' => $this->t('Provide an edit link to the @entity_type_label.', $t_arguments), 'id' => 'entity_link_edit']]; } if ($this->entityType->hasLinkTemplate('delete-form')) { $data['delete_' . $entity_type_id] = ['field' => ['title' => $this->t('Link to delete @entity_type_label', $t_arguments), 'help' => $this->t('Provide a delete link to the @entity_type_label.', $t_arguments), 'id' => 'entity_link_delete']]; } }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if ($this->targetEntityType->hasKey('bundle')) { $options = []; foreach ($this->entityTypeBundleInfo->getBundleInfo($this->targetEntityType->id()) as $bundle_id => $bundle_info) { $options[$bundle_id] = $bundle_info['label']; } $form['verf_target_bundles'] = [ '#type' => 'checkboxes', '#title' => $this->t('Target entity bundles to filter by'), '#options' => $options, '#default_value' => array_filter($this->options['verf_target_bundles']), ]; } return $form; }
/** * {@inheritdoc} */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { // The primary key field. $fields['id'] = BaseFieldDefinition::create('integer')->setLabel(t('Entity ID'))->setDescription(t('The ID of the eck entity.'))->setReadOnly(TRUE)->setSetting('unasigned', TRUE)->setDisplayConfigurable('view', TRUE); // Standard field, universal unique id. $fields['uuid'] = BaseFieldDefinition::create('uuid')->setLabel(t('UUID'))->setDescription(t('The UUID of the entity.'))->setReadOnly(TRUE); $fields['type'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Type'))->setDescription(t('The entity type.'))->setSetting('target_type', $entity_type->id() . '_type')->setReadOnly(TRUE); // Title field for the entity. $fields['title'] = BaseFieldDefinition::create('string')->setLabel(t('Title'))->setDescription(t('The title of the entity.'))->setRequired(TRUE)->setTranslatable(TRUE)->setDefaultValue('')->setSetting('max_length', 255)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'string', 'weight' => -5))->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -5))->setDisplayConfigurable('form', TRUE)->setDisplayConfigurable('view', TRUE); // The following base fields are set only if the user selected them. In the // future we need to find a better solution for defining this base fields. // @todo: Find a dynamic way to add base fields. // Owner field of the entity. $fields['uid'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Authored by'))->setDescription(t('The username of the entity author.'))->setSetting('target_type', 'user')->setSetting('handler', 'default')->setTranslatable(TRUE)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'author', 'weight' => 0))->setDisplayOptions('form', array('type' => 'entity_reference_autocomplete', 'weight' => 5, 'settings' => array('match_operator' => 'CONTAINS', 'size' => 60, 'placeholder' => '')))->setDisplayConfigurable('form', TRUE)->setDisplayConfigurable('view', TRUE); $fields['langcode'] = BaseFieldDefinition::create('language')->setLabel(t('Language'))->setDescription(t('The language code of the entity.'))->setTranslatable(TRUE)->setDisplayOptions('view', array('type' => 'hidden'))->setDisplayOptions('form', array('type' => 'language_select', 'weight' => 2))->setDisplayConfigurable('view', TRUE); $fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Authored on'))->setDescription(t('The time that the entity was created.'))->setTranslatable(TRUE)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'timestamp', 'weight' => 0))->setDisplayOptions('form', array('type' => 'datetime_timestamp', 'weight' => 10))->setDisplayConfigurable('form', TRUE)->setDisplayConfigurable('view', TRUE); $fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))->setDescription(t('The time that the entity was last edited.'))->setTranslatable(TRUE)->setDisplayConfigurable('view', TRUE); return $fields; }
/** * Alter field storage definitions for a content entity type. * * @param \Drupal\Core\Field\FieldStorageDefinitionInterface[] $fields * The array of field storage definitions for the entity type. * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type definition. * * @see hook_entity_field_storage_info() */ function hook_entity_field_storage_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) { // Alter the max_length setting. if ($entity_type->id() == 'node' && !empty($fields['mymodule_text'])) { $fields['mymodule_text']->setSetting('max_length', 128); } }
/** * Gets the type of the ID key for a given entity type. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * An entity type. * * @return string|null * The type of the ID key for a given entity type, or NULL if the entity * type does not support fields. */ 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(); }