You are here

public function ContentLoaderBase::importEntityField in YAML Content 8.2

Process import data into an appropriate field value and assign it.

Parameters

array $field_data: Field data read from the content file for import.

\Drupal\Core\Entity\EntityInterface $entity: The pre-built entity object being populated with field data.

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition for the field being populated.

2 calls to ContentLoaderBase::importEntityField()
ContentLoaderBase::importEntity in src/ContentLoader/ContentLoaderBase.php
Load an entity from a loaded import data outline.
ProcessedContentLoader::importEntityField in src/ContentLoader/ProcessedContentLoader.php
Process import data into an appropriate field value and assign it.
1 method overrides ContentLoaderBase::importEntityField()
ProcessedContentLoader::importEntityField in src/ContentLoader/ProcessedContentLoader.php
Process import data into an appropriate field value and assign it.

File

src/ContentLoader/ContentLoaderBase.php, line 233

Class

ContentLoaderBase
A base ContentLoader implementation to be extended by new content loaders.

Namespace

Drupal\yaml_content\ContentLoader

Code

public function importEntityField(array $field_data, EntityInterface $entity, FieldDefinitionInterface $field_definition) {

  // Iterate over each field value.
  foreach ($field_data as $field_item) {
    $field_value = $this
      ->importFieldItem($field_item, $entity, $field_definition);

    // Assign or append field item value.
    $this
      ->assignFieldValue($entity, $field_definition
      ->getName(), $field_value);
  }
}