Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityFieldDefinitionTrait.php

function 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();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal