diff --git a/src/UrlExtractor.php b/src/UrlExtractor.php index c6a03a4..6f89617 100644 --- a/src/UrlExtractor.php +++ b/src/UrlExtractor.php @@ -51,11 +51,12 @@ class UrlExtractor { return $this->getUrlFromEntity($input, $relative); } elseif ($input instanceof EntityReferenceFieldItemListInterface) { - if ($item = $input->first()) { + $item = $input->first(); + if (!empty($item) && $input->entity instanceof ContentEntityInterface) { return $this->getUrlFromEntity($item->entity, $relative); } } - elseif ($input instanceof EntityReferenceItem) { + elseif ($input instanceof EntityReferenceItem && $input->entity instanceof ContentEntityInterface) { return $this->getUrlFromEntity($input->entity, $relative); } elseif ($input instanceof LinkItemInterface) {