You are here

protected function Importer::copyFieldValues in Tome 8

Copies values from a denormalized entity to the original entity.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: The denormalized entity.

\Drupal\Core\Entity\FieldableEntityInterface $original_entity: The original entity.

See also

\Drupal\rest\Plugin\rest\resource\EntityResource::patch

1 call to Importer::copyFieldValues()
Importer::importContent in modules/tome_sync/src/Importer.php
Imports a content entity from the source storage.

File

modules/tome_sync/src/Importer.php, line 220

Class

Importer
Handles importing of content and file entities.

Namespace

Drupal\tome_sync

Code

protected function copyFieldValues(FieldableEntityInterface $entity, FieldableEntityInterface $original_entity) {
  foreach ($entity->_tomeFields as $field_name) {
    $field = $entity
      ->get($field_name);
    if ($entity
      ->getEntityType()
      ->hasKey('langcode') && $field_name === $entity
      ->getEntityType()
      ->getKey('langcode') && $field
      ->isEmpty()) {
      continue;
    }
    $original_entity
      ->set($field_name, $field
      ->getValue());
  }
}