Development

/plugins/sfGridPlugin/trunk/lib/routing/sfGridRoute.php

You must first sign up to be able to contribute.

root/plugins/sfGridPlugin/trunk/lib/routing/sfGridRoute.php

Revision 29168, 1.1 kB (checked in by Leon.van.der.Ree, 3 years ago)

fixed small naming issues

Line 
1 <?php
2 /**
3  * sfGridRoute represents a route that is bound to a Grid-class.
4  *
5  * A grid route can only represent a single Grid object.
6  *
7  * @package    symfony
8  * @subpackage routing
9  * @author     Leon van der Ree
10  * @version    SVN: $Id:  $
11  */
12 class sfGridRoute extends sfObjectRoute
13 {
14   public function __construct($pattern, array $defaults = array(), array $requirements = array(), array $options = array())
15   {
16     $options['type'] = 'object';
17     
18     parent::__construct($pattern, $defaults, $requirements, $options);
19   }
20  
21   protected function getObjectForParameters($parameters)
22   {
23     $className = $this->options['model'];
24     $grid = new $className();
25     
26     if (!$grid instanceof sfContextGrid)
27     {
28       throw new InvalidArgumentException('The model should extend sfContextGrid');
29     }
30     
31     if (isset($parameters['page']))
32     {
33       $grid->setPage($parameters['page']);
34     }
35     
36     if (isset($parameters['sort']))
37     {
38       $sort = $parameters['sort'];
39       $type = isset($parameters['type']) ? $parameters['type'] : null;
40       
41       $grid->setSort($sort, $type);
42     }
43         
44     return $grid;
45   }
46 }
47
Note: See TracBrowser for help on using the browser.