Book.php

Same filename in this branch
  1. 10 core/modules/book/src/Plugin/migrate/source/Book.php
Same filename and directory in other branches
  1. 9 core/modules/book/src/Plugin/migrate/destination/Book.php
  2. 9 core/modules/book/src/Plugin/migrate/source/Book.php
  3. 8.9.x core/modules/book/src/Plugin/migrate/destination/Book.php
  4. 8.9.x core/modules/book/src/Plugin/migrate/source/d6/Book.php
  5. 8.9.x core/modules/book/src/Plugin/migrate/source/Book.php
  6. 11.x core/modules/book/src/Plugin/migrate/destination/Book.php
  7. 11.x core/modules/book/src/Plugin/migrate/source/Book.php

Namespace

Drupal\book\Plugin\migrate\destination

File

core/modules/book/src/Plugin/migrate/destination/Book.php

View source
<?php

namespace Drupal\book\Plugin\migrate\destination;

use Drupal\Core\Entity\EntityInterface;
use Drupal\migrate\Attribute\MigrateDestination;
use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
use Drupal\migrate\Row;

/**
 * Provides migrate destination plugin for Book content.
 */
class Book extends EntityContentBase {
  
  /**
   * {@inheritdoc}
   */
  protected static function getEntityTypeId($plugin_id) {
    return 'node';
  }
  
  /**
   * {@inheritdoc}
   */
  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);
  }

}

Classes

Title Deprecated Summary
Book Provides migrate destination plugin for Book content.

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