You are here

protected function ContentEntityStorage::mongoToEntityData in MongoDB 8

Parameters

array $data: The data to be passed to the entity constructor.

array $record: The record as read from MongoDB.

array $definitions: Field definition array.

bool $translatable: Whether the entity is translatable.

string $default_langcode_key: The default_langcode key, typically default_langcode.

$langcode_key: The langcode key, typucally langcode.

1 call to ContentEntityStorage::mongoToEntityData()
ContentEntityStorage::loadFromMongo in src/Entity/ContentEntityStorage.php
Loads entity records from a MongoDB collections.

File

src/Entity/ContentEntityStorage.php, line 124
Contains Drupal\mongodb\Entity\ContentEntityStorage.

Class

ContentEntityStorage

Namespace

Drupal\mongodb\Entity

Code

protected function mongoToEntityData(array &$data, array $record, array $definitions, $translatable, $default_langcode_key, $langcode_key) {
  foreach ($record['values'] as $translation) {
    foreach ($definitions as $field_name => $definition) {
      if (isset($translation[$field_name])) {
        $index = $translatable && !$translation[$default_langcode_key][0]['value'] ? $translation[$langcode_key][0]['value'] : LanguageInterface::LANGCODE_DEFAULT;
        $data[$field_name][$index] = $translation[$field_name];
      }
    }
  }
}