You are here

public function EntityCollection::__construct in JSON:API 8

Instantiates a EntityCollection object.

Parameters

\Drupal\Core\Entity\EntityInterface|null[] $entities: The entities for the collection.

File

src/Resource/EntityCollection.php, line 43

Class

EntityCollection
Wrapper to normalize collections with multiple entities.

Namespace

Drupal\jsonapi\Resource

Code

public function __construct(array $entities) {
  assert(Inspector::assertAll(function ($entity) {
    return $entity === NULL || $entity instanceof EntityInterface || $entity instanceof EntityAccessDeniedHttpException;
  }, $entities));
  $this->entities = $entities;
}