ConfigureQueryContract
The ConfigureQueryContract defines how a list type registers joins and customizes its base SQL query structure.
Interface: HeimrichHannot\FlareBundle\Contract\ListType\ConfigureQueryContract
AbstractListType already implements this contract with no-op methods, so most list types only override the parts they
need.
Lifecycle
Before your methods run, Flare creates the query context with:
- A main table taken from
ListSpecification::$dcor thedataContainerconfigured on the list type descriptor mainas the default table aliasSELECT main.*GROUP BY main.id
Then Flare:
- Calls
configureTableRegistry() - Calls
configureBaseQuery() - Dispatches
QueryBaseInitializedEvent - Re-adds
main.id AS idto the select list for internal processing
Methods
configureTableRegistry(TableAliasRegistry $registry): void
Use this method to register joins and additional aliases on the TableAliasRegistry.
use HeimrichHannot\FlareBundle\Query\JoinTypeEnum;
use HeimrichHannot\FlareBundle\Query\SqlJoinStruct;
use HeimrichHannot\FlareBundle\Query\TableAliasRegistry;
public function configureTableRegistry(TableAliasRegistry $registry): void
{
$registry->registerJoin(new SqlJoinStruct(
fromAlias: TableAliasRegistry::ALIAS_MAIN,
joinType: JoinTypeEnum::LEFT,
table: 'tl_member',
joinAlias: 'member',
condition: $registry->makeJoinOn('member', 'id', TableAliasRegistry::ALIAS_MAIN, 'author')
));
}
configureBaseQuery(SqlQueryStruct $struct): void
Use this method to modify the pre-seeded SqlQueryStruct, for example by adding select fields, conditions, sorting, or
custom grouping.
use HeimrichHannot\FlareBundle\Query\SqlQueryStruct;
public function configureBaseQuery(SqlQueryStruct $struct): void
{
$select = $struct->getSelect() ?? [];
$select[] = 'member.username AS author_name';
$struct->setSelect($select);
$struct->setConditions('main.published = "1"');
}