mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 05:24:28 +02:00
Fixed problem that tables could not be sorted by manufacturers, categories, etc.
This commit is contained in:
parent
77a5cadf51
commit
c635637c00
2 changed files with 41 additions and 26 deletions
|
@ -55,6 +55,8 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
|
||||
private bool $use_simple_total = false;
|
||||
|
||||
private \Closure|null $query_modifier;
|
||||
|
||||
public function __construct(ManagerRegistry $registry = null)
|
||||
{
|
||||
parent::__construct($registry);
|
||||
|
@ -81,6 +83,10 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
*/
|
||||
$resolver->setDefault('simple_total_query', false);
|
||||
|
||||
//Add the possibility of a closure to modify the query builder before the query is executed
|
||||
$resolver->setDefault('query_modifier', null);
|
||||
$resolver->setAllowedTypes('query_modifier', ['null', \Closure::class]);
|
||||
|
||||
}
|
||||
|
||||
protected function afterConfiguration(array $options): void
|
||||
|
@ -88,6 +94,7 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
parent::afterConfiguration($options);
|
||||
$this->detailQueryCallable = $options['detail_query'];
|
||||
$this->use_simple_total = $options['simple_total_query'];
|
||||
$this->query_modifier = $options['query_modifier'];
|
||||
}
|
||||
|
||||
protected function prepareQuery(AdapterQuery $query): void
|
||||
|
@ -159,6 +166,11 @@ class TwoStepORMAdapter extends ORMAdapter
|
|||
;
|
||||
}
|
||||
|
||||
//Apply the query modifier, if set
|
||||
if ($this->query_modifier !== null) {
|
||||
$builder = $this->query_modifier->__invoke($builder);
|
||||
}
|
||||
|
||||
$id_query = $builder->getQuery();
|
||||
$event = new ORMAdapterQueryEvent($id_query);
|
||||
$state->getDataTable()->getEventDispatcher()->dispatch($event, ORMAdapterEvents::PRE_QUERY);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue