function ResourceTypeRepository::all
Same name in other branches
- 8.9.x 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
2 calls to ResourceTypeRepository::all()
- ResourceTypeRepository::get in core/
modules/ jsonapi/ src/ ResourceType/ ResourceTypeRepository.php - Gets a specific JSON:API resource type based on entity type ID and bundle.
- 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 119
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) {
return $cached->data;
}
$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 $resource_types;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.