You are here

protected function EntityFieldDefinitionTrait::getDefinitionFromEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/src/EntityFieldDefinitionTrait.php \Drupal\migrate\EntityFieldDefinitionTrait::getDefinitionFromEntity()

Gets the field definition from a specific entity base field.

The method takes the field ID as an argument and returns the field storage definition to be used in getIds() by querying the destination entity base field definition.

Parameters

string $key: The field ID key.

Return value

array An associative array with a structure that contains the field type, keyed as 'type', together with field storage settings as they are returned by FieldStorageDefinitionInterface::getSettings().

See also

\Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()

4 calls to EntityFieldDefinitionTrait::getDefinitionFromEntity()
ContentEntity::getIds in core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
Defines the source fields uniquely identifying a source row.
EntityContentBase::getIds in core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
Gets the destination IDs.
EntityContentComplete::getIds in core/modules/migrate/src/Plugin/migrate/destination/EntityContentComplete.php
Gets the destination IDs.
EntityRevision::getIds in core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
Gets the destination IDs.

File

core/modules/migrate/src/EntityFieldDefinitionTrait.php, line 27

Class

EntityFieldDefinitionTrait
The entity field definition trait.

Namespace

Drupal\migrate

Code

protected function getDefinitionFromEntity($key) {
  $plugin_id = $this
    ->getPluginId();
  $entity_type_id = $this
    ->getEntityTypeId($plugin_id);

  /** @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] $definitions */
  $definitions = $this->entityFieldManager
    ->getBaseFieldDefinitions($entity_type_id);
  $field_definition = $definitions[$key];
  return [
    'type' => $field_definition
      ->getType(),
  ] + $field_definition
    ->getSettings();
}