IncludeResolver
class IncludeResolver (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. |
Resolves included resources for an entity or collection of entities.
Properties
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected EntityAccessChecker | $entityAccessChecker | The JSON:API entity access checker. |
Methods
IncludeResolver constructor.
Resolves included resources.
Receives a tree of include field names and resolves resources for it.
Returns a tree of field names to include from an include parameter.
Resolves an array of public field paths.
Takes an array of exploded paths and builds a tree of field names.
Details
__construct(EntityTypeManagerInterface $entity_type_manager, EntityAccessChecker $entity_access_checker)
IncludeResolver constructor.
IncludedData
resolve(ResourceIdentifierInterface|ResourceObjectData $data, string $include_parameter)
Resolves included resources.
protected Data
resolveIncludeTree(array $include_tree, Data $data, Data $includes = NULL)
Receives a tree of include field names and resolves resources for it.
This method takes a tree of relationship field names and JSON:API Data object. For the top-level of the tree and for each entity in the collection, it gets the target entity type and IDs for each relationship field. The method then loads all of those targets and calls itself recursively with the next level of the tree and those loaded resources.
static protected array
toIncludeTree(ResourceObjectData $data, string $include_parameter)
Returns a tree of field names to include from an include parameter.
static protected array
resolveInternalIncludePaths(ResourceType $base_resource_type, array $paths)
Resolves an array of public field paths.
static protected array
buildTree(array $paths)
Takes an array of exploded paths and builds a tree of field names.
Input example: [ ['one', 'two', 'three'], ['one', 'two', 'four'], ['one', 'two', 'internal'], ]
Output example: [ 'one' => [ 'two' [ 'three' => [], 'four' => [], 'internal' => [], ], ], ]