You are here

public function EntityProcessorBase::getDefaultLanguageData 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::getDefaultLanguageData()
  2. 3.x src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::getDefaultLanguageData()

Return the data of the default language of the passed data.

2 calls to EntityProcessorBase::getDefaultLanguageData()
EntityProcessorBase::getEntityToImport in src/Processors/Entity/EntityProcessorBase.php
Return the entity to import.
TaxonomyTermProcessor::getEntityToImport in src/Plugin/content_synchronizer/entity_processor/TaxonomyTermProcessor.php
Return the entity to import.

File

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

Class

EntityProcessorBase
The entity processor base.

Namespace

Drupal\content_synchronizer\Processors\Entity

Code

public function getDefaultLanguageData(array $data, $filterOnEntityDefinition = TRUE) {
  if (count($data[self::KEY_TRANSLATIONS]) > 1) {
    foreach ($data[self::KEY_TRANSLATIONS] as $languageId => $translationData) {
      if (array_key_exists('default_langcode', $translationData) && $translationData['default_langcode'][0]['value'] == 1) {
        return $translationData;
      }
    }
  }

  // Get default data :
  $defaultData = reset($data[self::KEY_TRANSLATIONS]);
  if ($filterOnEntityDefinition) {

    // Filter on reference data field.
    $fieldDefinitions = \Drupal::entityTypeManager()
      ->getStorage($this
      ->getGlobalReferenceManager()
      ->getEntityTypeFromGid($data[ExportEntityWriter::FIELD_GID]))
      ->getFieldStorageDefinitions();
    return array_intersect_key($defaultData, $fieldDefinitions);
  }
  else {
    return $defaultData;
  }
}