public function AllDocs::execute in Replication 8
Same name and namespace in other branches
- 8.2 src/AllDocs/AllDocs.php \Drupal\replication\AllDocs\AllDocs::execute()
@todo {@link https://www.drupal.org/node/2599900 Move any logic around 'includeDocs' and the serialization format into the serializer to better separate concerns.}
Overrides AllDocsInterface::execute
File
- src/
AllDocs/ AllDocs.php, line 145
Class
Namespace
Drupal\replication\AllDocsCode
public function execute() {
$rows = [];
$entity_types = $this->entityTypeManager
->getDefinitions();
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($this->multiversionManager
->isEnabledEntityType($entity_type) && !$entity_type
->get('local')) {
try {
$query = $this->entityTypeManager
->getStorage($entity_type_id)
->getQuery();
if ($entity_type
->get('workspace') !== FALSE) {
$query
->condition('workspace', $this->workspace
->id());
}
$ids = $query
->execute();
} catch (\Exception $e) {
watchdog_exception('replication', $e);
continue;
}
$keys = [];
foreach ($ids as $id) {
$keys[] = $entity_type_id . ':' . $id;
}
$items = $this->entityIndex
->getMultiple($keys);
foreach ($items as $item) {
if ($item['is_stub'] == TRUE) {
continue;
}
$rows[$item['uuid']] = [
'rev' => $item['rev'],
];
}
if ($this->includeDocs) {
$entities = $this->entityTypeManager
->getStorage($entity_type_id)
->loadMultiple($ids);
foreach ($entities as $entity) {
if ($entity->_rev->is_stub) {
continue;
}
$rows[$entity
->uuid()]['doc'] = $this->serializer
->normalize($entity, 'json');
}
}
}
}
return $rows;
}