- Work done to allow more flexibility on based on whatever custom attributes were provided.
This commit is contained in:
1 parent
b3e792e20f
commit
bea01badb7
5 files changed
+21
-8
No files matched your search
+11
-3
@@ -31,7 +31,7 @@ class ApiRepository extends \Ulmus\Repository
|
||||
parent::__construct($entity, $alias, $adapter);
|
||||
}
|
||||
|
||||
public function loadOne(): ?object
|
||||
public function loadOne(): ? object
|
||||
{
|
||||
$response = $this->executeRequest(Attribute\Obj\Api\Read::class);
|
||||
|
||||
@@ -58,11 +58,19 @@ class ApiRepository extends \Ulmus\Repository
|
||||
{
|
||||
$attribute = $this->getApiAttribute($attributeClass);
|
||||
|
||||
if ($attribute === null) {
|
||||
throw new \RuntimeException(sprintf("Could not find attribute class '%s' for class '%s'", $attributeClass, $this->entityClass));
|
||||
}
|
||||
|
||||
$request = $this->prepareRequest($this->buildRequestUrl($attribute->url), $attribute->method, $data);
|
||||
|
||||
$request = $this->callApiRequestCallback($request, $attribute);
|
||||
|
||||
$this->lastResponse = $response = $this->adapter->adapter()->connect()->fromRequest($request);
|
||||
$rest = $this->adapter->adapter()->connect();
|
||||
|
||||
$rest->timeout = $attribute->timeout;
|
||||
|
||||
$this->lastResponse = $response = $rest->fromRequest($request);
|
||||
|
||||
$response = $this->callApiResponseCallback($response, $attribute);
|
||||
|
||||
@@ -126,7 +134,7 @@ class ApiRepository extends \Ulmus\Repository
|
||||
return new JsonRequest($uri, $method, $body === null ? Stream::fromTemp() : JsonStream::fromContent($body), $headers);
|
||||
}
|
||||
|
||||
public function getApiAttribute(string $type) : object
|
||||
public function getApiAttribute(string $type) : ? object
|
||||
{
|
||||
return $this->entityClass::resolveEntity()->getAttributeImplementing($type);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user