|
Revision 29168, 1.1 kB
(checked in by Leon.van.der.Ree, 3 years ago)
|
fixed small naming issues
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 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 |
|
|---|