refactor: improvemets
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -720,34 +720,21 @@ class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableI
|
||||
|
||||
// Node operations
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function nodeList(string|int|null $location = null, bool $recursive = false, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null): array {
|
||||
// null location is root
|
||||
if ($location === null) {
|
||||
$location = self::ROOT_ID;
|
||||
public function nodeList(string|int|null $collection = null, bool $recursive = false, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): array {
|
||||
if ($collection === null) {
|
||||
$collection = self::ROOT_ID;
|
||||
}
|
||||
return $this->metaStore->nodeList($this->serviceTenantId, $this->serviceUserId, $location, $recursive, $filter, $sort, $range);
|
||||
return $this->metaStore->nodeList($this->serviceTenantId, $this->serviceUserId, $collection, $recursive, $filter, $sort, $range, $properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function nodeListFilter(): IFilter {
|
||||
return new Filter($this->serviceAbilities[self::CAPABILITY_COLLECTION_LIST_FILTER] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function nodeListSort(): ISort {
|
||||
return new Sort($this->serviceAbilities[self::CAPABILITY_COLLECTION_LIST_SORT] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function nodeListRange(RangeType $type): IRange {
|
||||
if ($type !== RangeType::TALLY) {
|
||||
throw new InvalidParameterException("Invalid: Node range of type '{$type->value}' is not supported");
|
||||
@@ -755,11 +742,8 @@ class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableI
|
||||
return new RangeTally();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function nodeDelta(string|int|null $location, string $signature, bool $recursive = false, string $detail = 'ids'): array {
|
||||
return $this->metaStore->nodeDelta($this->serviceTenantId, $this->serviceUserId, $location, $signature, $recursive, $detail);
|
||||
public function nodeDelta(string|int|null $collection, string $signature, string $detail = 'ids'): Delta {
|
||||
return new Delta();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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