function EntityContentBase::import
Same name and namespace in other branches
- 9 core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php \Drupal\migrate\Plugin\migrate\destination\EntityContentBase::import()
- 8.9.x core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php \Drupal\migrate\Plugin\migrate\destination\EntityContentBase::import()
- 11.x core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php \Drupal\migrate\Plugin\migrate\destination\EntityContentBase::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 destination IDs from the previous import of this source row. This is empty the first time a source row is migrated. 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.
Throws
\Drupal\migrate\MigrateException When an entity cannot be looked up.
\Drupal\migrate\Exception\EntityValidationException When an entity validation hasn't been passed.
Overrides MigrateDestinationInterface::import
2 calls to EntityContentBase::import()
- EntityComment::import in core/
modules/ comment/ src/ Plugin/ migrate/ destination/ EntityComment.php - Import the row.
- EntityUser::import in core/
modules/ user/ src/ Plugin/ migrate/ destination/ EntityUser.php
2 methods override EntityContentBase::import()
- EntityComment::import in core/
modules/ comment/ src/ Plugin/ migrate/ destination/ EntityComment.php - Import the row.
- EntityUser::import in core/
modules/ user/ src/ Plugin/ migrate/ destination/ EntityUser.php
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentBase.php, line 165
Class
- EntityContentBase
- Provides destination class for all content entities lacking a specific class.
Namespace
Drupal\migrate\Plugin\migrate\destinationCode
public function import(Row $row, array $old_destination_id_values = []) {
$this->rollbackAction = MigrateIdMapInterface::ROLLBACK_DELETE;
$entity = $this->getEntity($row, $old_destination_id_values);
if (!$entity) {
throw new MigrateException('Unable to get entity');
}
assert($entity instanceof ContentEntityInterface);
if ($this->isEntityValidationRequired($entity)) {
$this->validateEntity($entity);
}
$ids = $this->save($entity, $old_destination_id_values);
if ($this->isTranslationDestination()) {
$ids[] = $entity->language()
->getId();
}
return $ids;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.