$resource_types =
[];
foreach ($this->entityTypeManager->
getDefinitions() as $entity_type) { $bundles =
array_keys($this->entityTypeBundleInfo->
getBundleInfo($entity_type->
id()));
$resource_types =
array_reduce($bundles,
function D
$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;
} /**
* Creates a ResourceType value object for the given entity type + bundle.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type to create a JSON:API resource type for.
* @param string $bundle
* The entity type bundle to create a JSON:API resource type for.
*
* @return \Drupal\jsonapi\ResourceType\ResourceType
* A JSON:API resource type.
*/