src/Resource/EntityCollection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Resource/EntityCollection.php b/src/Resource/EntityCollection.php index aca0fbd..26f0752 100644 --- a/src/Resource/EntityCollection.php +++ b/src/Resource/EntityCollection.php @@ -4,6 +4,7 @@ namespace Drupal\jsonapi\Resource; use Drupal\Component\Assertion\Inspector; use Drupal\Core\Entity\EntityInterface; +use Drupal\jsonapi\Exception\EntityAccessDeniedHttpException; /** * Wrapper to normalize collections with multiple entities. @@ -40,7 +41,7 @@ class EntityCollection implements \IteratorAggregate, \Countable { * The entities for the collection. */ public function __construct(array $entities) { - assert(Inspector::assertAll(function ($entity) { return $entity === NULL || $entity instanceof EntityInterface; }, $entities)); + assert(Inspector::assertAll(function ($entity) { return $entity === NULL || $entity instanceof EntityInterface || $entity instanceof EntityAccessDeniedHttpException; }, $entities)); $this->entities = $entities; }