refactor: improvemets
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -99,17 +99,21 @@ class Provider implements ProviderServiceMutateInterface, ProviderServiceDiscove
|
||||
public function serviceList(string $tenantId, string $userId, array $filter = []): array
|
||||
{
|
||||
$list = $this->serviceStore->list($tenantId, $userId, $filter);
|
||||
foreach ($list as $entry) {
|
||||
$service = new Service();
|
||||
$service->fromStore($entry);
|
||||
$list[$service->identifier()] = $service;
|
||||
foreach ($list as $serviceData) {
|
||||
$serviceInstance = $this->serviceFresh()->fromStore($serviceData);
|
||||
$list[$serviceInstance->identifier()] = $serviceInstance;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function serviceFetch(string $tenantId, string $userId, string|int $identifier): ?Service
|
||||
{
|
||||
return $this->serviceStore->fetch($tenantId, $userId, $identifier);
|
||||
$serviceData = $this->serviceStore->fetch($tenantId, $userId, $identifier);
|
||||
if ($serviceData === null) {
|
||||
return null;
|
||||
}
|
||||
$serviceInstance = $this->serviceFresh()->fromStore($serviceData);
|
||||
return $serviceInstance;
|
||||
}
|
||||
|
||||
public function serviceFindByAddress(string $tenantId, string $userId, string $address): ?Service
|
||||
@@ -129,7 +133,7 @@ class Provider implements ProviderServiceMutateInterface, ProviderServiceDiscove
|
||||
return $this->serviceStore->extant($tenantId, $userId, $identifiers);
|
||||
}
|
||||
|
||||
public function serviceFresh(): ResourceServiceMutateInterface
|
||||
public function serviceFresh(): Service
|
||||
{
|
||||
return new Service();
|
||||
}
|
||||
@@ -141,7 +145,7 @@ class Provider implements ProviderServiceMutateInterface, ProviderServiceDiscove
|
||||
}
|
||||
|
||||
$created = $this->serviceStore->create($tenantId, $userId, $service);
|
||||
return (string) $created->identifier();
|
||||
return (string) $created['id'];
|
||||
}
|
||||
|
||||
public function serviceModify(string $tenantId, string $userId, ResourceServiceMutateInterface $service): string
|
||||
@@ -151,7 +155,7 @@ class Provider implements ProviderServiceMutateInterface, ProviderServiceDiscove
|
||||
}
|
||||
|
||||
$updated = $this->serviceStore->modify($tenantId, $userId, $service);
|
||||
return (string) $updated->identifier();
|
||||
return (string) $updated['id'];
|
||||
}
|
||||
|
||||
public function serviceDestroy(string $tenantId, string $userId, ResourceServiceMutateInterface $service): bool
|
||||
|
||||
Reference in New Issue
Block a user