Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #74 from codepeak/main
Browse files Browse the repository at this point in the history
Make sure we do not get null as response
  • Loading branch information
edalzell authored Jan 9, 2022
2 parents 9422aa8 + 6af6f00 commit 8e48188
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Directives/GlobalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ class GlobalSet

public function handleKey(string $handle, string $key = null)
{
return $this->globalSet($handle)->get($key);
$globalSet = $this->globalSet($handle);

if (is_null($globalSet)) {
return null;
}

return $globalSet->get($key);
}

public function handle(string $handle)
Expand All @@ -26,6 +32,12 @@ public function handle(string $handle)

private function globalSet(string $handle)
{
return GlobalSetAPI::findByHandle($handle)->inCurrentSite();
$handle = GlobalSetAPI::findByHandle($handle);

if (is_null($handle)) {
return null;
}

return $handle->inCurrentSite();
}
}

0 comments on commit 8e48188

Please sign in to comment.