You are here

public function EntityProcessorBase::getDataToExport in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::getDataToExport()
  2. 3.x src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::getDataToExport()

Return the data to export.

Get the array of data to export in array format : [ "property_1"=>[ "value1", "value2"] "property_2"=>[ "value1"] ].

Parameters

\Drupal\Core\Entity\Entity $entityToExport: The entity to export.

Return value

array The data to export.

Overrides EntityProcessorInterface::getDataToExport

4 calls to EntityProcessorBase::getDataToExport()
EntityProcessorBase::export in src/Processors/Entity/EntityProcessorBase.php
Export the entity and return the gid if exists, else false.
FileProcessor::getDataToExport in src/Plugin/content_synchronizer/entity_processor/FileProcessor.php
Return the data to export.
NodeProcessor::getDataToExport in src/Plugin/content_synchronizer/entity_processor/NodeProcessor.php
Return the data to export.
TaxonomyTermProcessor::getDataToExport in src/Plugin/content_synchronizer/entity_processor/TaxonomyTermProcessor.php
Return the data to export.
4 methods override EntityProcessorBase::getDataToExport()
FileProcessor::getDataToExport in src/Plugin/content_synchronizer/entity_processor/FileProcessor.php
Return the data to export.
NodeProcessor::getDataToExport in src/Plugin/content_synchronizer/entity_processor/NodeProcessor.php
Return the data to export.
TaxonomyTermProcessor::getDataToExport in src/Plugin/content_synchronizer/entity_processor/TaxonomyTermProcessor.php
Return the data to export.
UserProcessor::getDataToExport in src/Plugin/content_synchronizer/entity_processor/UserProcessor.php
Return the data to export.

File

src/Processors/Entity/EntityProcessorBase.php, line 364

Class

EntityProcessorBase
The entity processor base.

Namespace

Drupal\content_synchronizer\Processors\Entity

Code

public function getDataToExport(Entity $entityToExport) {
  $dataToExport = [];

  // Get entity type keys :
  $contentEntityTypeKeys = $entityToExport
    ->getEntityType()
    ->getKeys();

  // Init properties not to export.
  $propertyIdsNotToExport = $this
    ->getPropertiesIdsNotToExportList();
  $propertyIdsNotToExport += array_intersect_key($contentEntityTypeKeys, array_flip($propertyIdsNotToExport));

  // Init keys like bundles.

  /** @var \Drupal\Core\Entity\ContentEntityType $contentEntityType */
  foreach ($contentEntityTypeKeys as $key => $name) {
    if (!in_array($name, $propertyIdsNotToExport)) {
      if (method_exists($entityToExport, $key)) {
        $dataToExport[$name] = $entityToExport
          ->{$key}();
      }
    }
  }
  foreach ($entityToExport
    ->getTypedData()
    ->getProperties() as $propertyId => $propertyData) {

    // Check properties to export :
    if (!in_array($propertyId, $propertyIdsNotToExport)) {

      /** @var \Drupal\content_synchronizer\Processors\Type\TypeProcessorBase $plugin */
      if ($plugin = $this
        ->getTypeProcessorManager()
        ->getInstanceByFieldType(get_class($propertyData))) {
        if ($fieldDataToExport = $plugin
          ->getExportedData($entityToExport
          ->get($propertyId))) {
          $dataToExport[$propertyId] = $fieldDataToExport;
        }
      }
    }
  }
  return $dataToExport;
}