ImportProcessor.php in Content Synchronizer 3.x
File
src/Processors/ImportProcessor.php
View source
<?php
namespace Drupal\content_synchronizer\Processors;
use Drupal\content_synchronizer\Entity\ImportEntity;
use Drupal\content_synchronizer\Processors\Entity\EntityProcessorPluginManager;
use Drupal\Core\Entity\EntityInterface;
class ImportProcessor {
const PUBLICATION_REVISION = 'publication_revision';
const PUBLICATION_UNPUBLISH = 'publication_unpublish';
const PUBLICATION_PUBLISH = 'publication_publish';
const DEFAULT_PUBLICATION_TYPE = 'publication_publish';
const UPDATE_SYSTEMATIC = 'update_systematic';
const UPDATE_IF_RECENT = 'update_if_recent';
const UPDATE_NO_UPDATE = 'update_no_update';
const DEFAULT_UPDATE_TYPE = 'update_if_recent';
private static $currentImportProcessor;
protected $import;
protected $entityProcessorPluginManager;
protected $creationType;
protected $updateType;
public function __construct(ImportEntity $import) {
$this->import = $import;
$this->entityProcessorPluginManager = \Drupal::service(EntityProcessorPluginManager::SERVICE_NAME);
}
public function importEntityFromRootData(array $rootData) : EntityInterface {
self::$currentImportProcessor = $this;
$entity = NULL;
$plugin = $this->entityProcessorPluginManager
->getInstanceByEntityType($rootData[ExportEntityWriter::FIELD_ENTITY_TYPE_ID]);
if ($entityData = $this->import
->getEntityDataFromGid($rootData[ExportEntityWriter::FIELD_GID])) {
$entity = $plugin
->import($entityData);
}
return $entity;
}
public static function getCurrentImportProcessor() {
return self::$currentImportProcessor;
}
public function getImport() {
return $this->import;
}
public function getCreationType() {
return $this->creationType;
}
public function setCreationType($creationType) {
$this->creationType = $creationType;
}
public function getUpdateType() {
return $this->updateType;
}
public function setUpdateType($updateType) {
$this->updateType = $updateType;
}
}