function Book::updateEntity

Same name and namespace in other branches
  1. 8.9.x core/modules/book/src/Plugin/migrate/destination/Book.php \Drupal\book\Plugin\migrate\destination\Book::updateEntity()
  2. 10 core/modules/book/src/Plugin/migrate/destination/Book.php \Drupal\book\Plugin\migrate\destination\Book::updateEntity()
  3. 11.x 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.