public function ResourceTypeRepository::getByTypeName in JSON:API 8
Same name and namespace in other branches
- 8.2 src/ResourceType/ResourceTypeRepository.php \Drupal\jsonapi\ResourceType\ResourceTypeRepository::getByTypeName()
Gets a specific JSON API resource type based on a supplied typename.
Parameters
string $type_name: The public typename of a JSON API resource.
Return value
\Drupal\jsonapi\ResourceType\ResourceType|null The resource type, or NULL if none found.
Overrides ResourceTypeRepositoryInterface::getByTypeName
File
- src/
ResourceType/ ResourceTypeRepository.php, line 137
Class
- ResourceTypeRepository
- Provides a repository of all JSON API resource types.
Namespace
Drupal\jsonapi\ResourceTypeCode
public function getByTypeName($type_name) {
foreach ($this
->all() as $resource) {
if ($resource
->getTypeName() == $type_name) {
return $resource;
}
}
return NULL;
}