Skip to content

Commit

Permalink
Prevent to throw ModelNotFoundException error when non active object …
Browse files Browse the repository at this point in the history
…is set for privacyPolicyObjType model
  • Loading branch information
Xavier committed Sep 5, 2024
1 parent b52e263 commit 632c043
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Charcoal/CookieConsent/Model/Structure/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Charcoal\CookieConsent\Model\Structure;

use Charcoal\CookieConsent\Exception\ModelNotFoundException;
use Charcoal\CookieConsent\Model\Repository\LinkRelationRepository;
use Charcoal\Model\ModelInterface;
use Charcoal\Property\Structure\StructureModel;
Expand Down Expand Up @@ -137,15 +138,19 @@ public function isSupportedTarget($target): bool
*/
public function getHref()
{
switch ($this->getType()) {
case self::TYPE_FILE:
return $this->getFilePath();
try {
switch ($this->getType()) {
case self::TYPE_FILE:
return $this->getFilePath();

case self::TYPE_MODEL:
return $this->getModel()['url'];
case self::TYPE_MODEL:
return $this->getModel()['url'];

case self::TYPE_URL:
return $this->getUrl();
case self::TYPE_URL:
return $this->getUrl();
}
} catch (ModelNotFoundException $e) {
return '';
}

return null;
Expand Down

0 comments on commit 632c043

Please sign in to comment.