ResourceTypeRepository
class ResourceTypeRepository implements ResourceTypeRepositoryInterface (View source)
| internal | JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it. |
Provides a repository of all JSON:API resource types.
Contains the complete set of ResourceType value objects, which are auto- generated based on the Entity Type Manager and Entity Type Bundle Info: one JSON:API resource type per entity type bundle. So, for example:
- node--article
- node--page
- node--…
- user--user
- …
Properties
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected EntityTypeBundleInfoInterface | $entityTypeBundleInfo | The bundle manager. |
|
| protected EntityFieldManagerInterface | $entityFieldManager | The entity field manager. |
|
| protected CacheBackendInterface | $cache | The cache backend. |
|
| protected EventDispatcherInterface | $eventDispatcher | The event dispatcher. |
|
| protected string[] | $cacheTags | Cache tags used for caching the repository. |
Methods
Instantiates a ResourceTypeRepository object.
Gets all JSON:API resource types.
Creates a ResourceType value object for the given entity type + bundle.
Gets a specific JSON:API resource type based on entity type ID and bundle.
Gets a specific JSON:API resource type based on a supplied typename.
Gets the field mapping for the given field names and entity type + bundle.
Gets all field names for a given entity type and bundle.
Whether an entity type + bundle maps to a mutable resource type.
Whether an entity type + bundle maps to a locatable resource type.
Whether an entity type is a versionable resource type.
Calculates relatable JSON:API resource types for a given resource type.
Get relatable resource types from a field definition.
Determines if a given field definition is a reference field.
Gets all bundle IDs for a given entity type.
Lookup a resource type by entity type ID and bundle name.
Details
__construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_bundle_info, EntityFieldManagerInterface $entity_field_manager, CacheBackendInterface $cache, EventDispatcherInterface $dispatcher)
Instantiates a ResourceTypeRepository object.
ResourceType[]
all()
Gets all JSON:API resource types.
protected ResourceType
createResourceType(EntityTypeInterface $entity_type, string $bundle)
Creates a ResourceType value object for the given entity type + bundle.
ResourceType
get(string $entity_type_id, string $bundle)
Gets a specific JSON:API resource type based on entity type ID and bundle.
ResourceType|null
getByTypeName(string $type_name)
Gets a specific JSON:API resource type based on a supplied typename.
protected ResourceTypeField[]
getFields(array $field_names, EntityTypeInterface $entity_type, string $bundle)
Gets the field mapping for the given field names and entity type + bundle.
protected string[]
getAllFieldNames(EntityTypeInterface $entity_type, string $bundle)
Gets all field names for a given entity type and bundle.
static protected bool
isMutableResourceType(EntityTypeInterface $entity_type, string $bundle)
Whether an entity type + bundle maps to a mutable resource type.
static protected bool
isLocatableResourceType(EntityTypeInterface $entity_type, string $bundle)
Whether an entity type + bundle maps to a locatable resource type.
static protected bool
isVersionableResourceType(EntityTypeInterface $entity_type)
Whether an entity type is a versionable resource type.
protected array
calculateRelatableResourceTypes(ResourceType $resource_type, array $resource_types)
Calculates relatable JSON:API resource types for a given resource type.
This method has no affect after being called once.
protected ResourceType[]
getRelatableResourceTypesFromFieldDefinition(FieldDefinitionInterface $field_definition, array $resource_types)
Get relatable resource types from a field definition.
protected bool
isReferenceFieldDefinition(FieldDefinitionInterface $field_definition)
Determines if a given field definition is a reference field.
protected string[]
getAllBundlesForEntityType(string $entity_type_id)
Gets all bundle IDs for a given entity type.
static protected ResourceType|null
lookupResourceType(array $resource_types, string $entity_type_id, string $bundle)
Lookup a resource type by entity type ID and bundle name.