function ResourceObject::__construct
Same name in other branches
- 9 core/modules/jsonapi/src/JsonApiResource/ResourceObject.php \Drupal\jsonapi\JsonApiResource\ResourceObject::__construct()
- 8.9.x core/modules/jsonapi/src/JsonApiResource/ResourceObject.php \Drupal\jsonapi\JsonApiResource\ResourceObject::__construct()
- 11.x 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.
\Drupal\Core\Language\LanguageInterface|null $language: (optional) The resource language.
File
-
core/
modules/ jsonapi/ src/ JsonApiResource/ ResourceObject.php, line 91
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, ?LanguageInterface $language = NULL) {
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);
// If the specified language empty it falls back the same way as in the entity system
// @see \Drupal\Core\Entity\EntityBase::language()
$this->language = $language ?: new Language([
'id' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.