function ResourceTypeRepository::get
Same name in other branches
- 9 core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::get()
- 8.9.x core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::get()
- 11.x core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::get()
File
-
core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php, line 187
Class
- ResourceTypeRepository
- Provides a repository of all JSON:API resource types.
Namespace
Drupal\jsonapi\ResourceTypeCode
public function get($entity_type_id, $bundle) {
assert(is_string($bundle) && !empty($bundle), 'A bundle ID is required. Bundleless entity types should pass the entity type ID again.');
if (empty($entity_type_id)) {
throw new PreconditionFailedHttpException('Server error. The current route is malformed.');
}
$map_id = sprintf('jsonapi.resource_type.%s.%s', $entity_type_id, $bundle);
$cached = $this->cache
->get($map_id);
if ($cached) {
return $cached->data;
}
$resource_type = static::lookupResourceType($this->all(), $entity_type_id, $bundle);
$this->cache
->set($map_id, $resource_type, Cache::PERMANENT, $this->cacheTags);
return $resource_type;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.