EntityContentBase.php in Multiversion 8
File
src/Plugin/migrate/source/EntityContentBase.php
View source
<?php
namespace Drupal\multiversion\Plugin\migrate\source;
class EntityContentBase extends SourcePluginBase {
protected function initializeIterator() {
$last_definition = $this->entityManager
->getLastInstalledDefinition($this->entityTypeId);
$storage_class = $last_definition
->getStorageClass();
$last_storage = $this->entityManager
->createHandlerInstance($storage_class, $last_definition);
$entities = $last_storage
->loadMultiple();
$results = [];
foreach ($entities as $entity_id => $entity) {
if (isset($entity->_deleted->value) && $entity->_deleted->value) {
continue;
}
foreach ($entity
->getTranslationLanguages(TRUE) as $language) {
$result = [];
foreach ($entity
->getTranslation($language
->getId()) as $field_name => $field) {
if (!$field
->isEmpty()) {
$value = $field
->getValue();
if (count($value) == 1) {
$value = reset($value);
if (count($value) == 1 && empty($value['langcode'])) {
$value = reset($value);
}
}
$result[$field_name] = $value;
}
}
$results[] = $result;
}
}
return new \ArrayIterator(array_values($results));
}
}