RelationResolver
Finds relations for a RelationalFieldType field such as: - inline - select with foreign_table or MM - group with allowed or MM - category - file
Files are handled differently with specific File / FileReference objects instead of general Record objects. Therefore, resolveFileReferences() is used.
What it does to the outside world:
- You have a record and a field with relations and you get a collection of the related raw DB records.
What it hides:
- How the DB queries are made.
The result is usually wrapped in a Closure, so it is only called when needed, however this piece of code does not care about how it is used.
not part of public API, as this needs to be streamlined and proven.
Table of Contents
Properties
- $greedyDatabaseBackend : GreedyDatabaseBackend
- $resourceFactory : ResourceFactory
- $runtimeCache : FrontendInterface
Methods
- __construct() : mixed
-
resolve()
: array<int, array{table: string, row: array
}> - This method currently returns an array with "table" and "row" pairs, but will probably return something else in the future.
- resolveFileReferences() : array<string|int, FileReference>
- getGroupedRelationIds() : array<int, array<string, mixed>>
- We currently use the RelationHandler to resolve all records attached to a given field.
-
getRelationalRows()
: array<string, array<int, array{table: string, row: array
}>> - Find the relations relevant for this field. This could be multiple tables!
Properties
$greedyDatabaseBackend
protected
GreedyDatabaseBackend
$greedyDatabaseBackend
$resourceFactory
protected
ResourceFactory
$resourceFactory
$runtimeCache
protected
FrontendInterface
$runtimeCache
Attributes
- #[Autowire]
- $service: 'cache.runtime'
Methods
__construct()
public
__construct(FrontendInterface $runtimeCache, ResourceFactory $resourceFactory, GreedyDatabaseBackend $greedyDatabaseBackend) : mixed
Parameters
- $runtimeCache : FrontendInterface
- $resourceFactory : ResourceFactory
- $greedyDatabaseBackend : GreedyDatabaseBackend
resolve()
This method currently returns an array with "table" and "row" pairs, but will probably return something else in the future.
public
resolve(RecordInterface $record, FieldTypeInterface $fieldInformation, Context $context) : array<int, array{table: string, row: array}>
Parameters
- $record : RecordInterface
- $fieldInformation : FieldTypeInterface
- $context : Context
Return values
array<int, array{table: string, row: arrayresolveFileReferences()
public
resolveFileReferences(RecordInterface $record, FieldTypeInterface $fieldInformation, Context $context) : array<string|int, FileReference>
Parameters
- $record : RecordInterface
- $fieldInformation : FieldTypeInterface
- $context : Context
Return values
array<string|int, FileReference>getGroupedRelationIds()
We currently use the RelationHandler to resolve all records attached to a given field.
protected
getGroupedRelationIds(RecordInterface $record, FieldTypeInterface $fieldInformation, Context $context) : array<int, array<string, mixed>>
Parameters
- $record : RecordInterface
- $fieldInformation : FieldTypeInterface
- $context : Context
Tags
Return values
array<int, array<string, mixed>>getRelationalRows()
Find the relations relevant for this field. This could be multiple tables!
protected
getRelationalRows(array<string|int, mixed> $necessaryRelationsOfRequestedField, Context $context) : array<string, array<int, array{table: string, row: array}>>
Note: While $necessaryRelationsOfRequestedField is sorted, the result will be the plain unsorted database rows.
Parameters
- $necessaryRelationsOfRequestedField : array<string|int, mixed>
- $context : Context