public function ResourceObject::__construct in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/src/JsonApiResource/ResourceObject.php \Drupal\jsonapi\JsonApiResource\ResourceObject::__construct()
ResourceObject constructor.
Parameters
\Drupal\Core\Cache\CacheableDependencyInterface $cacheability: The cacheability for the resource object.
\Drupal\jsonapi\ResourceType\ResourceType $resource_type: The JSON:API resource type of the resource object.
string $id: The resource object's ID.
mixed|null $revision_id: The resource object's version identifier. NULL, if the resource object is not versionable.
array $fields: An array of the resource object's fields, keyed by public field name.
\Drupal\jsonapi\JsonApiResource\LinkCollection $links: The links for the resource object.
File
- core/
modules/ jsonapi/ src/ JsonApiResource/ ResourceObject.php, line 80
Class
- ResourceObject
- Represents a JSON:API resource object.
Namespace
Drupal\jsonapi\JsonApiResourceCode
public function __construct(CacheableDependencyInterface $cacheability, ResourceType $resource_type, $id, $revision_id, array $fields, LinkCollection $links) {
assert(is_null($revision_id) || $resource_type
->isVersionable());
$this
->setCacheability($cacheability);
$this->resourceType = $resource_type;
$this->resourceIdentifier = new ResourceIdentifier($resource_type, $id);
$this->versionIdentifier = $revision_id ? 'id:' . $revision_id : NULL;
$this->fields = $fields;
$this->links = $links
->withContext($this);
}