protected function EntityContentBase::updateEntity in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php \Drupal\migrate\Plugin\migrate\destination\EntityContentBase::updateEntity()
Update an entity with the new values from row.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to update.
\Drupal\migrate\Row $row: The row object to update from.
1 call to EntityContentBase::updateEntity()
- EntityRevision::getEntity in core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityRevision.php - Get the entity.
2 methods override EntityContentBase::updateEntity()
- Book::updateEntity in core/
modules/ book/ src/ Plugin/ migrate/ destination/ Book.php - Update an entity with the new values from row.
- EntityRevision::updateEntity in core/
modules/ migrate/ tests/ src/ Unit/ destination/ EntityRevisionTest.php - Don't test method from base class.
File
- core/
modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentBase.php, line 132 - Contains \Drupal\migrate\Plugin\migrate\destination\EntityContentBase.
Class
- EntityContentBase
- The destination class for all content entities lacking a specific class.
Namespace
Drupal\migrate\Plugin\migrate\destinationCode
protected function updateEntity(EntityInterface $entity, Row $row) {
// If the migration has specified a list of properties to be overwritten,
// clone the row with an empty set of destination values, and re-add only
// the specified properties.
if (isset($this->configuration['overwrite_properties'])) {
$clone = $row
->cloneWithoutDestination();
foreach ($this->configuration['overwrite_properties'] as $property) {
$clone
->setDestinationProperty($property, $row
->getDestinationProperty($property));
}
$row = $clone;
}
foreach ($row
->getDestination() as $field_name => $values) {
$field = $entity->{$field_name};
if ($field instanceof TypedDataInterface) {
$field
->setValue($values);
}
}
$this
->setRollbackAction($row
->getIdMap());
}