mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
moved sorting logic from template to sorter.
This commit is contained in:
parent
b525265d88
commit
7b7d4d3021
3 changed files with 15 additions and 1 deletions
|
|
@ -42,7 +42,8 @@ class AddressController extends ContainerAware
|
|||
|
||||
return $this->container->get('templating')->renderResponse('SyliusAddressingBundle:Backend/Address:list.html.twig', array(
|
||||
'addresses' => $addresses,
|
||||
'paginator' => $paginator
|
||||
'paginator' => $paginator,
|
||||
'sorter' => $addressSorter
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,4 +54,16 @@ class AddressSorter extends ContainerAware implements SorterInterface
|
|||
/** @var QueryBuilder */
|
||||
$sortable->orderBy('a.' . $sortProperty, $sortOrder);
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
$sortOrder = $this->container->get('request')->query->get('order', 'ASC');
|
||||
|
||||
if (!in_array($sortOrder, array('ASC', 'DESC'))) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return ($sortOrder == 'ASC') ? 'DESC' : 'ASC';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,5 @@ namespace Sylius\Bundle\AddressingBundle\Sorting;
|
|||
interface SorterInterface
|
||||
{
|
||||
function sort($sortable);
|
||||
function getOrder();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue