function Entity::getEntity
Same name in other branches
- 9 core/modules/migrate/src/Plugin/migrate/destination/Entity.php \Drupal\migrate\Plugin\migrate\destination\Entity::getEntity()
- 8.9.x core/modules/migrate/src/Plugin/migrate/destination/Entity.php \Drupal\migrate\Plugin\migrate\destination\Entity::getEntity()
- 10 core/modules/migrate/src/Plugin/migrate/destination/Entity.php \Drupal\migrate\Plugin\migrate\destination\Entity::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 are importing into.
7 calls to Entity::getEntity()
- EntityConfigBase::import in core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityConfigBase.php - EntityContentBase::import in core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentBase.php - EntityFile::getEntity in core/
modules/ file/ src/ Plugin/ migrate/ destination/ EntityFile.php - EntityImageStyle::import in core/
modules/ image/ src/ Plugin/ migrate/ destination/ EntityImageStyle.php - Import the row.
- EntityNodeType::getEntity in core/
modules/ node/ src/ Plugin/ migrate/ destination/ EntityNodeType.php
7 methods override Entity::getEntity()
- EntityContentComplete::getEntity in core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentComplete.php - Gets the entity.
- EntityFile::getEntity in core/
modules/ file/ src/ Plugin/ migrate/ destination/ EntityFile.php - EntityNodeType::getEntity in core/
modules/ node/ src/ Plugin/ migrate/ destination/ EntityNodeType.php - EntityRevision::getEntity in core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityRevision.php - Gets the entity.
- EntityShortcutSet::getEntity in core/
modules/ shortcut/ src/ Plugin/ migrate/ destination/ EntityShortcutSet.php
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ Entity.php, line 166
Class
- Entity
- Provides a generic destination to import entities.
Namespace
Drupal\migrate\Plugin\migrate\destinationCode
protected function getEntity(Row $row, array $old_destination_id_values) {
$entity_id = reset($old_destination_id_values) ?: $this->getEntityId($row);
if (!empty($entity_id) && ($entity = $this->storage
->load($entity_id))) {
// Allow updateEntity() to change the entity.
$entity = $this->updateEntity($entity, $row) ?: $entity;
}
else {
// Attempt to ensure we always have a bundle.
if ($bundle = $this->getBundle($row)) {
$row->setDestinationProperty($this->getKey('bundle'), $bundle);
}
// Stubs might need some required fields filled in.
if ($row->isStub()) {
$this->processStubRow($row);
}
$entity = $this->storage
->create($row->getDestination());
$entity->enforceIsNew();
}
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.