You are here

public function TaxonomyTermProcessor::getDataToExport in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/content_synchronizer/entity_processor/TaxonomyTermProcessor.php \Drupal\content_synchronizer\Plugin\content_synchronizer\entity_processor\TaxonomyTermProcessor::getDataToExport()
  2. 3.x src/Plugin/content_synchronizer/entity_processor/TaxonomyTermProcessor.php \Drupal\content_synchronizer\Plugin\content_synchronizer\entity_processor\TaxonomyTermProcessor::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 EntityProcessorBase::getDataToExport

File

src/Plugin/content_synchronizer/entity_processor/TaxonomyTermProcessor.php, line 140

Class

TaxonomyTermProcessor
Plugin implementation of the 'accordion' formatter.

Namespace

Drupal\content_synchronizer\Plugin\content_synchronizer\entity_processor

Code

public function getDataToExport(Entity $entityToExport) {

  // Init data to export:
  $data = parent::getDataToExport($entityToExport);

  // Get parents Terms.
  $data['parents'] = [];
  $parents = $this
    ->getParentsTerms($entityToExport);
  if (!empty($parents)) {
    $plugin = $this
      ->getEntityProcessorManager()
      ->getInstanceByEntityType($entityToExport
      ->getEntityTypeId());
    foreach ($parents as $parent) {
      if ($parentGid = $plugin
        ->export($parent)) {
        $data['parents'][] = $parentGid;
      }
    }
  }
  return $data;
}