function ResourceTypeRepository::all
Same name in other branches
- 9 core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::all()
- 10 core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::all()
- 11.x core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::all()
Overrides ResourceTypeRepositoryInterface::all
1 call to ResourceTypeRepository::all()
- ResourceTypeRepository::getByTypeName in core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php - Gets a specific JSON:API resource type based on a supplied typename.
File
-
core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php, line 118
Class
- ResourceTypeRepository
- Provides a repository of all JSON:API resource types.
Namespace
Drupal\jsonapi\ResourceTypeCode
public function all() {
$cached = $this->cache
->get('jsonapi.resource_types', FALSE);
if ($cached === FALSE) {
$resource_types = [];
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type) {
$bundles = array_keys($this->entityTypeBundleInfo
->getBundleInfo($entity_type->id()));
$resource_types = array_reduce($bundles, function ($resource_types, $bundle) use ($entity_type) {
$resource_type = $this->createResourceType($entity_type, (string) $bundle);
return array_merge($resource_types, [
$resource_type->getTypeName() => $resource_type,
]);
}, $resource_types);
}
foreach ($resource_types as $resource_type) {
$relatable_resource_types = $this->calculateRelatableResourceTypes($resource_type, $resource_types);
$resource_type->setRelatableResourceTypes($relatable_resource_types);
}
$this->cache
->set('jsonapi.resource_types', $resource_types, Cache::PERMANENT, $this->cacheTags);
}
return $cached ? $cached->data : $resource_types;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.