Skip to content

Commit 4e62857

Browse files
Merge pull request #22 from netlogix/throw-exception-if-relationships-undefined
feat: throw exception if payload.relationships undefined
2 parents cd03004 + f4be126 commit 4e62857

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Classes/Domain/Model/ResourceProxy.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
use GuzzleHttp\Psr7\Uri;
14-
use Neos\Flow\Annotations as Flow;
14+
use JsonSchema\Exception\RuntimeException;
1515
use Netlogix\JsonApiOrg\Consumer\Service\ConsumerBackendInterface;
1616

1717
class ResourceProxy implements \ArrayAccess
@@ -92,6 +92,12 @@ public function getJsonApiOrgResourceIdentifier()
9292

9393
protected function loadRelationship(string $propertyName)
9494
{
95+
if (!array_key_exists('relationships', $this->payload)) {
96+
$typeName = $this->type->getTypeName();
97+
throw new RuntimeException(
98+
"relationships['$propertyName'] could not be loaded for $typeName. payload['relationships'] is not defined.",
99+
1723619674);
100+
}
95101
if (array_key_exists('data', $this->payload['relationships'][$propertyName])) {
96102
return;
97103
}

0 commit comments

Comments
 (0)