Skip to content

Commit cbb97e2

Browse files
committed
BUGFIX: Adds checks for local assets
1 parent 3d1abb1 commit cbb97e2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Classes/GraphQL/Resolver/Type/AssetResolver.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AssetResolver
5757
*/
5858
public function label(Types\Asset $asset): ?string
5959
{
60-
$localAssetData = $this->assetSourceContext->getAssetByLocalIdentifier($asset->localId);
60+
$localAssetData = $asset->localId ? $this->assetSourceContext->getAssetByLocalIdentifier($asset->localId) : null;
6161
if ($localAssetData && $localAssetData->getTitle()) {
6262
return $localAssetData->getTitle();
6363
}
@@ -82,6 +82,9 @@ public function isInUse(Types\Asset $asset): bool
8282
*/
8383
public function caption(Types\Asset $asset): ?string
8484
{
85+
if (!$asset->localId) {
86+
return null;
87+
}
8588
$localAssetData = $this->assetSourceContext->getAssetByLocalIdentifier($asset->localId);
8689
return $localAssetData instanceof Asset ? $localAssetData->getCaption() : null;
8790
}
@@ -149,6 +152,9 @@ public function iptcProperties(Types\Asset $asset): Types\IptcProperties
149152

150153
public function copyrightNotice(Types\Asset $asset): ?string
151154
{
155+
if (!$asset->localId) {
156+
return null;
157+
}
152158
$localAssetData = $this->assetSourceContext->getAssetByLocalIdentifier($asset->localId);
153159
return $localAssetData instanceof Asset ? $localAssetData->getCopyrightNotice() : null;
154160
}
@@ -161,6 +167,9 @@ public function lastModified(Types\Asset $asset): ?string
161167

162168
public function tags(Types\Asset $asset): Types\Tags
163169
{
170+
if (!$asset->localId) {
171+
return Types\Tags::empty();
172+
}
164173
$localAssetData = $this->assetSourceContext->getAssetByLocalIdentifier($asset->localId);
165174
return $localAssetData instanceof Asset ?
166175
Types\Tags::fromArray(
@@ -175,6 +184,9 @@ public function tags(Types\Asset $asset): Types\Tags
175184

176185
public function collections(Types\Asset $asset): Types\AssetCollections
177186
{
187+
if (!$asset->localId) {
188+
return Types\AssetCollections::empty();
189+
}
178190
$localAssetData = $this->assetSourceContext->getAssetByLocalIdentifier($asset->localId);
179191
return $localAssetData instanceof Asset ?
180192
Types\AssetCollections::fromArray(

0 commit comments

Comments
 (0)