refactor: nodeList generator
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -334,7 +334,7 @@ class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableI
|
||||
// If not forcing, ensure the collection is empty
|
||||
if (!$force) {
|
||||
$children = $this->metaStore->nodeList($this->serviceTenantId, $this->serviceUserId, $identifier, false);
|
||||
if (!empty($children)) {
|
||||
if ($children->valid()) {
|
||||
throw new InvalidParameterException("Collection is not empty: $identifier");
|
||||
}
|
||||
}
|
||||
@@ -808,18 +808,11 @@ class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableI
|
||||
|
||||
// Node operations (unified collections + entities)
|
||||
|
||||
public function nodeList(string|int|null $location, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null): array {
|
||||
public function nodeList(string|int|null $location, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null): Generator {
|
||||
$location = $this->normalizeLocation($location);
|
||||
$entries = $this->metaStore->nodeList($this->serviceTenantId, $this->serviceUserId, $location, false, $filter, $sort, $range);
|
||||
// cache nodes
|
||||
foreach ($entries as $id => $node) {
|
||||
if ($node instanceof CollectionResource) {
|
||||
$this->serviceCollectionCache[$id] = $node;
|
||||
} elseif ($node instanceof EntityResource) {
|
||||
$this->serviceEntityCache[$id] = $node;
|
||||
}
|
||||
}
|
||||
return $entries;
|
||||
// Do not retain yielded nodes in the service caches: large consumers must
|
||||
// be able to release each node as they advance through the cursor.
|
||||
yield from $this->metaStore->nodeList($this->serviceTenantId, $this->serviceUserId, $location, false, $filter, $sort, $range);
|
||||
}
|
||||
|
||||
public function nodeListFilter(): IFilter {
|
||||
|
||||
Reference in New Issue
Block a user