You are here

class ImportProcessor in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Processors/ImportProcessor.php \Drupal\content_synchronizer\Processors\ImportProcessor
  2. 3.x src/Processors/ImportProcessor.php \Drupal\content_synchronizer\Processors\ImportProcessor

Import processor.

Hierarchy

Expanded class hierarchy of ImportProcessor

10 files declare their use of ImportProcessor
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
EntityPublisher.php in src/Service/EntityPublisher.php
EntityReferenceFieldItemListProcessor.php in src/Plugin/content_synchronizer/type_processor/EntityReferenceFieldItemListProcessor.php

... See full list

File

src/Processors/ImportProcessor.php, line 11

Namespace

Drupal\content_synchronizer\Processors
View source
class ImportProcessor {
  const PUBLICATION_REVISION = 'publication_revision';
  const PUBLICATION_UNPUBLISH = 'publication_unpublish';
  const PUBLICATION_PUBLISH = 'publication_publish';
  const UPDATE_SYSTEMATIC = 'update_systematic';
  const UPDATE_IF_RECENT = 'update_if_recent';
  const UPDATE_NO_UPDATE = 'update_no_update';

  /**
   * The current import processor.
   *
   * @var ImportProcessor
   */
  private static $currentImportProcessor;

  /**
   * The import entity to treat.
   *
   * @var \Drupal\content_synchronizer\Entity\ImportEntity
   */
  protected $import;

  /**
   * The entity processor plugin manager.
   *
   * @var \Drupal\content_synchronizer\Processors\Entity\EntityProcessorPluginManager
   */
  protected $entityProcessorPluginManager;
  protected $creationType;
  protected $updateType;

  /**
   * {@inheritdoc}
   */
  public function __construct(ImportEntity $import) {
    $this->import = $import;
    $this->entityProcessorPluginManager = \Drupal::service(EntityProcessorPluginManager::SERVICE_NAME);
  }

  /**
   * Import the entity from the root data of the import.
   */
  public function importEntityFromRootData(array $rootData) {
    self::$currentImportProcessor = $this;

    // Get the plugin of the entity :

    /** @var \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase $plugin */
    $plugin = $this->entityProcessorPluginManager
      ->getInstanceByEntityType($rootData[ExportEntityWriter::FIELD_ENTITY_TYPE_ID]);
    if ($entityData = $this->import
      ->getEntityDataFromGid($rootData[ExportEntityWriter::FIELD_GID])) {
      $plugin
        ->import($entityData);
    }
  }

  /**
   * Get the current Import Processor.
   *
   * @return \Drupal\content_synchronizer\Processors\ImportProcessor
   *   The current import processor
   */
  public static function getCurrentImportProcessor() {
    return self::$currentImportProcessor;
  }

  /**
   * Get the import.
   *
   * @return \Drupal\content_synchronizer\Entity\ImportEntity
   *   The import entity.
   */
  public function getImport() {
    return $this->import;
  }

  /**
   * Get the creation type.
   *
   * @return mixed
   *   The creation type.
   */
  public function getCreationType() {
    return $this->creationType;
  }

  /**
   * Set the creation type.
   *
   * @param mixed $creationType
   *   The creation type.
   */
  public function setCreationType($creationType) {
    $this->creationType = $creationType;
  }

  /**
   * The update type.
   *
   * @return mixed
   *   The update type.
   */
  public function getUpdateType() {
    return $this->updateType;
  }

  /**
   * The update type.
   *
   * @param mixed $updateType
   *   The update type.
   */
  public function setUpdateType($updateType) {
    $this->updateType = $updateType;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ImportProcessor::$creationType protected property
ImportProcessor::$currentImportProcessor private static property The current import processor.
ImportProcessor::$entityProcessorPluginManager protected property The entity processor plugin manager.
ImportProcessor::$import protected property The import entity to treat.
ImportProcessor::$updateType protected property
ImportProcessor::getCreationType public function Get the creation type.
ImportProcessor::getCurrentImportProcessor public static function Get the current Import Processor.
ImportProcessor::getImport public function Get the import.
ImportProcessor::getUpdateType public function The update type.
ImportProcessor::importEntityFromRootData public function Import the entity from the root data of the import.
ImportProcessor::PUBLICATION_PUBLISH constant
ImportProcessor::PUBLICATION_REVISION constant
ImportProcessor::PUBLICATION_UNPUBLISH constant
ImportProcessor::setCreationType public function Set the creation type.
ImportProcessor::setUpdateType public function The update type.
ImportProcessor::UPDATE_IF_RECENT constant
ImportProcessor::UPDATE_NO_UPDATE constant
ImportProcessor::UPDATE_SYSTEMATIC constant
ImportProcessor::__construct public function