class ExportProcessor in Content Synchronizer 8
Same name and namespace in other branches
- 8.2 src/Processors/ExportProcessor.php \Drupal\content_synchronizer\Processors\ExportProcessor
- 3.x src/Processors/ExportProcessor.php \Drupal\content_synchronizer\Processors\ExportProcessor
Export Processor.
Hierarchy
- class \Drupal\content_synchronizer\Processors\ExportProcessor
Expanded class hierarchy of ExportProcessor
4 files declare their use of ExportProcessor
- ContentSynchronizerCommands.php in src/
Commands/ ContentSynchronizerCommands.php - content_synchronizer.drush.inc in ./
content_synchronizer.drush.inc - Drush commands for content_synchronizer module.
- EntityProcessorBase.php in src/
Processors/ Entity/ EntityProcessorBase.php - FileProcessor.php in src/
Plugin/ content_synchronizer/ entity_processor/ FileProcessor.php
File
- src/
Processors/ ExportProcessor.php, line 11
Namespace
Drupal\content_synchronizer\ProcessorsView source
class ExportProcessor {
/**
* The current export processor.
*
* @var ExportProcessor
*/
private static $currentExportProcessor;
/**
* The writer.
*
* @var ExportEntityWriter
*/
protected $writer;
/**
* The entity processor plugiin manager.
*
* @var \Drupal\content_synchronizer\Processors\Entity\EntityProcessorPluginManager
*/
protected $entityProcessorPluginManager;
/**
* {@inheritdoc}
*/
public function __construct(ExportEntityWriter $writer) {
$this->writer = $writer;
$this->entityProcessorPluginManager = \Drupal::service(EntityProcessorPluginManager::SERVICE_NAME);
}
/**
* Export the list of entities.
*/
public function exportEntitiesList(array $entities) {
self::$currentExportProcessor = $this;
foreach ($entities as $entity) {
// Get the plugin of the entity :
/** @var \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase $plugin */
$plugin = $this->entityProcessorPluginManager
->getInstanceByEntityType($entity
->getEntityTypeId());
$plugin
->export($entity);
$this->writer
->addRootEntity($entity);
}
}
/**
* Export the entity.
*
* @param \Drupal\Core\Entity\Entity $entity
* THe entity to export.
*/
public function exportEntity(Entity $entity) {
$this
->exportEntitiesList([
$entity,
]);
}
/**
* Get the current Export Processor.
*
* @return \Drupal\content_synchronizer\Processors\ExportProcessor
* The current export processor.
*/
public static function getCurrentExportProcessor() {
return self::$currentExportProcessor;
}
/**
* Get the writer.
*
* @return \Drupal\content_synchronizer\Processors\ExportEntityWriter
* The writer.
*/
public function getWriter() {
return $this->writer;
}
/**
* Delete the unzip files after process.
*/
public function closeProcess() {
$this->writer
->archiveFiles();
if ($archive = $this->writer
->getArchiveUri()) {
return $archive;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExportProcessor:: |
private static | property | The current export processor. | |
ExportProcessor:: |
protected | property | The entity processor plugiin manager. | |
ExportProcessor:: |
protected | property | The writer. | |
ExportProcessor:: |
public | function | Delete the unzip files after process. | |
ExportProcessor:: |
public | function | Export the list of entities. | |
ExportProcessor:: |
public | function | Export the entity. | |
ExportProcessor:: |
public static | function | Get the current Export Processor. | |
ExportProcessor:: |
public | function | Get the writer. | |
ExportProcessor:: |
public | function |