refactor: standardize protocol
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -41,7 +41,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly SessionTenant $tenantIdentity,
|
private readonly SessionTenant $tenantIdentity,
|
||||||
private readonly SessionIdentity $userIdentity,
|
private readonly SessionIdentity $userIdentity,
|
||||||
private Manager $chronoManager,
|
private readonly Manager $manager,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sources->jsonDeserialize($data['sources']);
|
$sources->jsonDeserialize($data['sources']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->providerList($tenantId, $userId, $sources);
|
return $this->manager->providerList($tenantId, $userId, $sources);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->providerFetch($tenantId, $userId, $data['identifier']);
|
return $this->manager->providerFetch($tenantId, $userId, $data['identifier']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function providerExtant(string $tenantId, string $userId, array $data): mixed {
|
private function providerExtant(string $tenantId, string $userId, array $data): mixed {
|
||||||
@@ -180,7 +180,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sources = new SourceSelector();
|
$sources = new SourceSelector();
|
||||||
$sources->jsonDeserialize($data['sources']);
|
$sources->jsonDeserialize($data['sources']);
|
||||||
|
|
||||||
return $this->chronoManager->providerExtant($tenantId, $userId, $sources);
|
return $this->manager->providerExtant($tenantId, $userId, $sources);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sources->jsonDeserialize($data['sources']);
|
$sources->jsonDeserialize($data['sources']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->serviceList($tenantId, $userId, $sources);
|
return $this->manager->serviceList($tenantId, $userId, $sources);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->serviceFetch($tenantId, $userId, $data['provider'], $data['identifier']);
|
return $this->manager->serviceFetch($tenantId, $userId, $data['provider'], $data['identifier']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function serviceExtant(string $tenantId, string $userId, array $data): mixed {
|
private function serviceExtant(string $tenantId, string $userId, array $data): mixed {
|
||||||
@@ -228,7 +228,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sources = new SourceSelector();
|
$sources = new SourceSelector();
|
||||||
$sources->jsonDeserialize($data['sources']);
|
$sources->jsonDeserialize($data['sources']);
|
||||||
|
|
||||||
return $this->chronoManager->serviceExtant($tenantId, $userId, $sources);
|
return $this->manager->serviceExtant($tenantId, $userId, $sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function serviceCreate(string $tenantId, string $userId, array $data): mixed {
|
private function serviceCreate(string $tenantId, string $userId, array $data): mixed {
|
||||||
@@ -245,7 +245,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->serviceCreate(
|
return $this->manager->serviceCreate(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -273,7 +273,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->serviceUpdate(
|
return $this->manager->serviceUpdate(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -296,7 +296,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->serviceDelete(
|
return $this->manager->serviceDelete(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -317,7 +317,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException('Either a service identifier or location and identity must be provided for service test');
|
throw new InvalidArgumentException('Either a service identifier or location and identity must be provided for service test');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->serviceTest(
|
return $this->manager->serviceTest(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -339,7 +339,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$filter = $data['filter'] ?? null;
|
$filter = $data['filter'] ?? null;
|
||||||
$sort = $data['sort'] ?? null;
|
$sort = $data['sort'] ?? null;
|
||||||
|
|
||||||
return $this->chronoManager->collectionList($tenantId, $userId, $sources, $filter, $sort);
|
return $this->manager->collectionList($tenantId, $userId, $sources, $filter, $sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function collectionExtant(string $tenantId, string $userId, array $data): mixed {
|
private function collectionExtant(string $tenantId, string $userId, array $data): mixed {
|
||||||
@@ -353,7 +353,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sources = new SourceSelector();
|
$sources = new SourceSelector();
|
||||||
$sources->jsonDeserialize($data['sources']);
|
$sources->jsonDeserialize($data['sources']);
|
||||||
|
|
||||||
return $this->chronoManager->collectionExtant($tenantId, $userId, $sources);
|
return $this->manager->collectionExtant($tenantId, $userId, $sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function collectionFetch(string $tenantId, string $userId, array $data): mixed {
|
private function collectionFetch(string $tenantId, string $userId, array $data): mixed {
|
||||||
@@ -376,7 +376,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_COLLECTION);
|
throw new InvalidArgumentException(self::ERR_INVALID_COLLECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->collectionFetch(
|
return $this->manager->collectionFetch(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -408,7 +408,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->collectionCreate(
|
return $this->manager->collectionCreate(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -444,7 +444,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->collectionUpdate(
|
return $this->manager->collectionUpdate(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -474,7 +474,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->collectionDelete(
|
return $this->manager->collectionDelete(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -501,7 +501,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sort = $data['sort'] ?? null;
|
$sort = $data['sort'] ?? null;
|
||||||
$range = $data['range'] ?? null;
|
$range = $data['range'] ?? null;
|
||||||
|
|
||||||
return $this->chronoManager->entityList($tenantId, $userId, $sources, $filter, $sort, $range);
|
return $this->manager->entityList($tenantId, $userId, $sources, $filter, $sort, $range);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,7 +531,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIERS);
|
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->entityFetch(
|
return $this->manager->entityFetch(
|
||||||
$tenantId,
|
$tenantId,
|
||||||
$userId,
|
$userId,
|
||||||
$data['provider'],
|
$data['provider'],
|
||||||
@@ -552,7 +552,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sources = new SourceSelector();
|
$sources = new SourceSelector();
|
||||||
$sources->jsonDeserialize($data['sources']);
|
$sources->jsonDeserialize($data['sources']);
|
||||||
|
|
||||||
return $this->chronoManager->entityExtant($tenantId, $userId, $sources);
|
return $this->manager->entityExtant($tenantId, $userId, $sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function entityCreate(string $tenantId, string $userId, array $data = []): mixed {
|
private function entityCreate(string $tenantId, string $userId, array $data = []): mixed {
|
||||||
@@ -572,7 +572,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
}
|
}
|
||||||
$options = $data['options'] ?? [];
|
$options = $data['options'] ?? [];
|
||||||
|
|
||||||
return $this->chronoManager->entityCreate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $properties, $options);
|
return $this->manager->entityCreate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $properties, $options);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,7 +595,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException('Invalid parameter: properties must be an array');
|
throw new InvalidArgumentException('Invalid parameter: properties must be an array');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->entityUpdate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier'], $properties);
|
return $this->manager->entityUpdate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier'], $properties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,7 +614,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->chronoManager->entityDelete($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier']);
|
return $this->manager->entityDelete($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ class DefaultController extends ControllerAbstract {
|
|||||||
$sources = new SourceSelector();
|
$sources = new SourceSelector();
|
||||||
$sources->jsonDeserialize($data['sources']);
|
$sources->jsonDeserialize($data['sources']);
|
||||||
|
|
||||||
return $this->chronoManager->entityDelta($tenantId, $userId, $sources);
|
return $this->manager->entityDelta($tenantId, $userId, $sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ class Manager {
|
|||||||
// retrieve provider and service
|
// retrieve provider and service
|
||||||
$provider = $this->providerFetch($tenantId, $userId, $providerId);
|
$provider = $this->providerFetch($tenantId, $userId, $providerId);
|
||||||
if ($provider instanceof ProviderServiceMutateInterface === false) {
|
if ($provider instanceof ProviderServiceMutateInterface === false) {
|
||||||
throw new InvalidArgumentException("Provider '$providerId' does not support service creation");
|
throw new InvalidArgumentException("Provider '$providerId' does not support service modification");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch existing service
|
// Fetch existing service
|
||||||
|
|||||||
Reference in New Issue
Block a user