You are here

public function EntityNodeType::import in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php \Drupal\node\Plugin\migrate\destination\EntityNodeType::import()
  2. 10 core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php \Drupal\node\Plugin\migrate\destination\EntityNodeType::import()

Import the row.

Derived classes must implement import(), to construct one new object (pre-populated) using ID mappings in the Migration.

Parameters

\Drupal\migrate\Row $row: The row object.

array $old_destination_id_values: (optional) The old destination IDs. Defaults to an empty array.

Return value

array|bool An indexed array of destination IDs in the same order as defined in the plugin's getIds() method if the plugin wants to save the IDs to the ID map, TRUE to indicate success without saving IDs to the ID map, or FALSE to indicate a failure.

Overrides EntityConfigBase::import

File

core/modules/node/src/Plugin/migrate/destination/EntityNodeType.php, line 18

Class

EntityNodeType
Plugin annotation @MigrateDestination( id = "entity:node_type" )

Namespace

Drupal\node\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {
  $entity_ids = parent::import($row, $old_destination_id_values);
  if ($row
    ->getDestinationProperty('create_body')) {
    $node_type = $this->storage
      ->load(reset($entity_ids));
    node_add_body_field($node_type, $row
      ->getDestinationProperty('create_body_label'));
  }
  return $entity_ids;
}