function JsonApiDocumentTopLevel::__construct
Same name in other branches
- 9 core/modules/jsonapi/src/JsonApiResource/JsonApiDocumentTopLevel.php \Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel::__construct()
- 8.9.x core/modules/jsonapi/src/JsonApiResource/JsonApiDocumentTopLevel.php \Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel::__construct()
- 10 core/modules/jsonapi/src/JsonApiResource/JsonApiDocumentTopLevel.php \Drupal\jsonapi\JsonApiResource\JsonApiDocumentTopLevel::__construct()
Instantiates a JsonApiDocumentTopLevel object.
Parameters
\Drupal\jsonapi\JsonApiResource\TopLevelDataInterface|\Drupal\jsonapi\JsonApiResource\ErrorCollection $data: The data to normalize. It can be either a ResourceObject, or a stand-in for one, or a collection of the same.
\Drupal\jsonapi\JsonApiResource\IncludedData $includes: A JSON:API Data object containing resources to be included in the response document or NULL if there should not be includes.
\Drupal\jsonapi\JsonApiResource\LinkCollection $links: A collection of links to resources related to the top-level document.
array $meta: (optional) The metadata to normalize.
File
-
core/
modules/ jsonapi/ src/ JsonApiResource/ JsonApiDocumentTopLevel.php, line 69
Class
- JsonApiDocumentTopLevel
- Represents a JSON:API document's "top level".
Namespace
Drupal\jsonapi\JsonApiResourceCode
public function __construct($data, IncludedData $includes, LinkCollection $links, array $meta = []) {
assert($data instanceof TopLevelDataInterface || $data instanceof ErrorCollection);
assert(!$data instanceof ErrorCollection || $includes instanceof NullIncludedData);
$this->data = $data instanceof TopLevelDataInterface ? $data->getData() : $data;
$this->includes = $includes->getData();
$this->links = $data instanceof TopLevelDataInterface ? $data->getMergedLinks($links->withContext($this)) : $links->withContext($this);
$this->meta = $data instanceof TopLevelDataInterface ? $data->getMergedMeta($meta) : $meta;
$this->omissions = $data instanceof TopLevelDataInterface ? OmittedData::merge($data->getOmissions(), $includes->getOmissions()) : $includes->getOmissions();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.