protected function EntityFile::getEntity in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/file/src/Plugin/migrate/destination/EntityFile.php \Drupal\file\Plugin\migrate\destination\EntityFile::getEntity()
Creates or loads an entity.
Parameters
\Drupal\migrate\Row $row: The row object.
array $old_destination_id_values: The old destination ids.
Return value
\Drupal\Core\Entity\EntityInterface The entity we're importing into.
Overrides Entity::getEntity
1 method overrides EntityFile::getEntity()
- TestEntityFile::getEntity in core/
modules/ file/ src/ Tests/ Migrate/ EntityFileTest.php - Creates or loads an entity.
File
- core/
modules/ file/ src/ Plugin/ migrate/ destination/ EntityFile.php, line 83 - Contains \Drupal\file\Plugin\migrate\destination\EntityFile.
Class
- EntityFile
- Every migration that uses this destination must have an optional dependency on the d6_file migration to ensure it runs first.
Namespace
Drupal\file\Plugin\migrate\destinationCode
protected function getEntity(Row $row, array $old_destination_id_values) {
// For stub rows, there is no real file to deal with, let the stubbing
// process take its default path.
if ($row
->isStub()) {
return parent::getEntity($row, $old_destination_id_values);
}
$destination = $row
->getDestinationProperty($this->configuration['destination_path_property']);
$entity = $this->storage
->loadByProperties([
'uri' => $destination,
]);
if ($entity) {
return reset($entity);
}
else {
return parent::getEntity($row, $old_destination_id_values);
}
}