public function testMultiSortIsResolvedProperlyWithOverridenDefaults() { $factory = new SortOptionsFactory('sort', 'dir', 'sorts'); $sorts = $factory->create(array('props' => 'test:asc'), array('multi_sort_parameter' => 'props'))->getSorts(); $this->assertCount(1, $sorts); $this->assertEquals(new Sort('test', 'ASC'), $sorts[0]); }
/** * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); $attributes = $request->attributes; if (($config = $attributes->get('_sort', false)) === false) { return; } if (!is_array($config)) { $config = array(); } $request->attributes->set('sort', $this->factory->create($request->query->all(), $config)); }