You are here

public function EntityReferenceFieldItemListProcessor::getExportedData in Content Synchronizer 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/content_synchronizer/type_processor/EntityReferenceFieldItemListProcessor.php \Drupal\content_synchronizer\Plugin\content_synchronizer\type_processor\EntityReferenceFieldItemListProcessor::getExportedData()
  2. 3.x src/Plugin/content_synchronizer/type_processor/EntityReferenceFieldItemListProcessor.php \Drupal\content_synchronizer\Plugin\content_synchronizer\type_processor\EntityReferenceFieldItemListProcessor::getExportedData()

Return export data array.

Parameters

\Drupal\Core\TypedData\TypedData $propertyData: The propertyData.

Return value

array export data.

Overrides TypeProcessorBase::getExportedData

File

src/Plugin/content_synchronizer/type_processor/EntityReferenceFieldItemListProcessor.php, line 47

Class

EntityReferenceFieldItemListProcessor
Plugin implementation For the type processor .

Namespace

Drupal\content_synchronizer\Plugin\content_synchronizer\type_processor

Code

public function getExportedData(TypedData $propertyData) {
  $data = [];

  // Init processor service.

  /** @var \Drupal\content_synchronizer\Processors\Entity\EntityProcessorPluginManager $entityProcessorManager */
  $entityProcessorManager = \Drupal::service(EntityProcessorPluginManager::SERVICE_NAME);

  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  $order = 0;
  foreach ($propertyData
    ->referencedEntities() as $entity) {

    /** @var \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase $plugin */
    $plugin = $entityProcessorManager
      ->getInstanceByEntityType($entity
      ->getEntityTypeId());
    if (get_class($entity) != "Drupal\\user\\Entity\\User") {
      if ($gid = $plugin
        ->export($entity)) {
        $data[$order] = $gid;
        $order++;
      }
    }
  }
  return $data;
}