public function ProcessedContentLoader::importFieldItem in YAML Content 8.2
Process import data for an individual field list item value.
Parameters
array|string $field_item_data: Field data for the individual field item as 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.
Return value
mixed The processed field item value for storage in the field.
Overrides ContentLoaderBase::importFieldItem
File
- src/
ContentLoader/ ProcessedContentLoader.php, line 96
Class
- ProcessedContentLoader
- A ContentLoader supporting processing of content through plugins.
Namespace
Drupal\yaml_content\ContentLoaderCode
public function importFieldItem($field_item_data, EntityInterface $entity, FieldDefinitionInterface $field_definition) {
// Preprocess field data.
$field_context['entity'] = $entity;
$field_context['field'] = $field_definition;
if (is_array($field_item_data)) {
$this
->preprocessData($field_item_data, $field_context);
}
$item_value = parent::importFieldItem($field_item_data, $entity, $field_definition);
// Postprocess loaded field data.
if (is_array($field_item_data)) {
$this
->postprocessData($field_item_data, $item_value, $field_context);
}
return $item_value;
}