refactor: improvemets
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -545,14 +545,14 @@ class MetaStore {
|
||||
|
||||
// For non-recursive, filter by parent
|
||||
if (!$recursive) {
|
||||
$query['pid'] = $location;
|
||||
$query['cid'] = $location;
|
||||
} elseif ($location !== null) {
|
||||
// For recursive with specific location, we need to get all descendants
|
||||
// This requires getting all collections first and building a list of IDs
|
||||
$allCollectionIds = $this->getDescendantCollectionIds($tenantId, $userId, $location);
|
||||
$allCollectionIds[] = $location;
|
||||
$query['$or'] = [
|
||||
['pid' => ['$in' => $allCollectionIds]],
|
||||
['cid' => ['$in' => $allCollectionIds]],
|
||||
['nid' => ['$in' => $allCollectionIds]],
|
||||
];
|
||||
}
|
||||
@@ -578,13 +578,13 @@ class MetaStore {
|
||||
$cursor = $this->_store->selectCollection($this->_NodeTable)->find($query, $options);
|
||||
$list = [];
|
||||
foreach ($cursor as $entry) {
|
||||
$nodeType = $entry['type'] ?? NodeType::Entity->value;
|
||||
$nodeType = $entry['type'];
|
||||
if ($nodeType === NodeType::Collection->value) {
|
||||
$node = (new NodeCollection())->fromStore($entry);
|
||||
} else {
|
||||
$node = (new CollectionResource())->fromStore($entry);
|
||||
} else if ($nodeType === NodeType::Entity->value) {
|
||||
$node = (new EntityResource())->fromStore($entry);
|
||||
}
|
||||
$list[$node->id()] = $node;
|
||||
$list[$node->identifier()] = $node;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user