|
Revision 11471, 2.1 kB
(checked in by fabien, 5 years ago)
|
[1.2] added a lot of REST goodness to symfony 1.2 (live from symfony camp)
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfRouteCollection implements Iterator |
|---|
| 20 |
{ |
|---|
| 21 |
protected |
|---|
| 22 |
$count = 0, |
|---|
| 23 |
$options = array(), |
|---|
| 24 |
$routes = array(); |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
* Constructor. |
|---|
| 28 |
* |
|---|
| 29 |
* @param array $options An array of options |
|---|
| 30 |
*/ |
|---|
| 31 |
public function __construct(array $options) |
|---|
| 32 |
{ |
|---|
| 33 |
if (!isset($options['name'])) |
|---|
| 34 |
{ |
|---|
| 35 |
throw new InvalidArgumentException('You must pass a "name" option to sfRouteCollection'); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
$this->options = $options; |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
* Returns the routes. |
|---|
| 43 |
* |
|---|
| 44 |
* @return array The routes |
|---|
| 45 |
*/ |
|---|
| 46 |
public function getRoutes() |
|---|
| 47 |
{ |
|---|
| 48 |
return $this->routes; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
* Returns the options. |
|---|
| 53 |
* |
|---|
| 54 |
* @return array The options |
|---|
| 55 |
*/ |
|---|
| 56 |
public function getOptions() |
|---|
| 57 |
{ |
|---|
| 58 |
return $this->options; |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
* Reset the error array to the beginning (implements the Iterator interface). |
|---|
| 63 |
*/ |
|---|
| 64 |
public function rewind() |
|---|
| 65 |
{ |
|---|
| 66 |
reset($this->routes); |
|---|
| 67 |
|
|---|
| 68 |
$this->count = count($this->routes); |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
* Get the name of the current route (implements the Iterator interface). |
|---|
| 73 |
* |
|---|
| 74 |
* @return string The key |
|---|
| 75 |
*/ |
|---|
| 76 |
public function key() |
|---|
| 77 |
{ |
|---|
| 78 |
return key($this->routes); |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
* Returns the current route (implements the Iterator interface). |
|---|
| 83 |
* |
|---|
| 84 |
* @return mixed The escaped value |
|---|
| 85 |
*/ |
|---|
| 86 |
public function current() |
|---|
| 87 |
{ |
|---|
| 88 |
return current($this->routes); |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
* Moves to the next route (implements the Iterator interface). |
|---|
| 93 |
*/ |
|---|
| 94 |
public function next() |
|---|
| 95 |
{ |
|---|
| 96 |
next($this->routes); |
|---|
| 97 |
|
|---|
| 98 |
--$this->count; |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
* Returns true if the current route is valid (implements the Iterator interface). |
|---|
| 103 |
* |
|---|
| 104 |
* @return boolean The validity of the current route; true if it is valid |
|---|
| 105 |
*/ |
|---|
| 106 |
public function valid() |
|---|
| 107 |
{ |
|---|
| 108 |
return $this->count > 0; |
|---|
| 109 |
} |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|