You are here

protected function Book::updateEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/book/src/Plugin/migrate/destination/Book.php \Drupal\book\Plugin\migrate\destination\Book::updateEntity()
  2. 9 core/modules/book/src/Plugin/migrate/destination/Book.php \Drupal\book\Plugin\migrate\destination\Book::updateEntity()

Updates an entity with the new values from row.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to update.

\Drupal\migrate\Row $row: The row object to update from.

Return value

\Drupal\Core\Entity\EntityInterface An updated entity from row values.

Overrides EntityContentBase::updateEntity

File

core/modules/book/src/Plugin/migrate/destination/Book.php, line 27

Class

Book
Plugin annotation @MigrateDestination( id = "book", provider = "book" )

Namespace

Drupal\book\Plugin\migrate\destination

Code

protected function updateEntity(EntityInterface $entity, Row $row) {
  if ($entity->book) {
    $book = $row
      ->getDestinationProperty('book');
    foreach ($book as $key => $value) {
      $entity->book[$key] = $value;
    }
  }
  else {
    $entity->book = $row
      ->getDestinationProperty('book');
  }
  return parent::updateEntity($entity, $row);
}