function EntityFieldDefinitionTrait::getDefinitionFromEntity

Same name in other branches
  1. 9 core/modules/migrate/src/EntityFieldDefinitionTrait.php \Drupal\migrate\EntityFieldDefinitionTrait::getDefinitionFromEntity()
  2. 8.9.x core/modules/migrate/src/EntityFieldDefinitionTrait.php \Drupal\migrate\EntityFieldDefinitionTrait::getDefinitionFromEntity()
  3. 11.x 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();
}

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