src/Bridge/Doctrine/ORM/Event/Subscriber/ORMSubscriber.php
public function addOrder(ORMFilterEvent $event)
    {
        $queryBuilder = $event->getQueryBuilder();
        $admin = $event->getAdmin();
        $actionConfiguration = $admin->getAction()->getConfiguration();

        $request = $this->requestStack->getMasterRequest();
        $sort = $request->get('sort');
        $alias = $queryBuilder->getRootAliases()[0];

        // The sort from the request override the configured one
        if ($sort) {
            $order = $request->get('order', 'asc');

            $queryBuilder->addOrderBy($alias.'.'.$sort, $order);
        } else {
            foreach ($actionConfiguration->getParameter('order') as $field => $order) {
                $queryBuilder->addOrderBy($alias.'.'.$field, $order);
            }
        }
    }
public function addOrder(ORMFilterEvent $event)
    {
        $queryBuilder = $event->getQueryBuilder();
        $admin = $event->getAdmin();
        $actionConfiguration = $admin->getAction()->getConfiguration();

        $request = $this->requestStack->getMasterRequest();
        $sort = $request->get('sort');
        $alias = $queryBuilder->getRootAliases()[0];

        // The sort from the request override the configured one
        if ($sort) {
            $order = $request->get('order', 'asc');

            $queryBuilder->addOrderBy($alias.'.'.$sort, $order);
        } else {
            foreach ($actionConfiguration->getParameter('order') as $field => $order) {
                $queryBuilder->addOrderBy($alias.'.'.$field, $order);
            }
        }
    }
public function addOrder ( ORMFilterEvent $ event ) { $ queryBuilder = $ event -> getQueryBuilder ( ) ; $ admin = $ event -> getAdmin ( ) ; $ actionConfiguration = $ admin -> getAction ( ) -> getConfiguration ( ) ; $ request = $ this -> requestStack -> getMasterRequest ( ) ; $ sort = $ request -> get ( 'sort' ) ; $ alias = $ queryBuilder -> getRootAliases ( ) [ 0 ] ; // The sort from the request override the configured one if ( $ sort ) { $ order = $ request -> get ( 'order' , 'asc' ) ; $ queryBuilder -> addOrderBy ( $ alias . '.' . $ sort , $ order ) ; } else { foreach ( $ actionConfiguration -> getParameter ( 'order' ) as $ field => $ order ) { $ queryBuilder -> addOrderBy ( $ alias . '.' . $ field , $ order ) ; } } }
Add the order to query builder according to the configuration.

@param ORMFilterEvent $event
Add the order to query builder according to the configuration .