public function EntityPublisher::saveEntity in Content Synchronizer 3.x
Same name and namespace in other branches
- 8.2 src/Service/EntityPublisher.php \Drupal\content_synchronizer\Service\EntityPublisher::saveEntity()
- 8 src/Service/EntityPublisher.php \Drupal\content_synchronizer\Service\EntityPublisher::saveEntity()
Save the entity after import.
If the entity is revisionable, it creates a new revision. If the entity is new and is a root entity, then it is unpublished.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to save.
string $gid: The gid of the entity.
\Drupal\Core\Entity\EntityInterface $existingEntity: The existing entity.
array $dataToImport: The data to import.
File
- src/
Service/ EntityPublisher.php, line 60
Class
- EntityPublisher
- THe entity publsher service.
Namespace
Drupal\content_synchronizer\ServiceCode
public function saveEntity(EntityInterface $entity, $gid = NULL, EntityInterface $existingEntity = NULL, array $dataToImport = []) {
// Alter entity before import.
$entityDataToImport = array_key_exists('translations', $dataToImport) ? $dataToImport['translations'][$entity
->language()
->getId()] : $dataToImport;
$this->moduleHandler
->alter(EntityProcessorBase::IMPORT_HOOK, $entity, $existingEntity, $entityDataToImport);
// Try to create a new revision of the current entity.
$this
->saveEntityWithRevision($entity, $gid, $existingEntity);
}