1. sfRouteCollection.class.php
  2. /** * sfObjectRouteCollection represents a collection of routes. * * @package symfony * @subpackage routing * @author Fabien Potencier * @version SVN: $Id: sfRouteCollection.class.php 11471 2008-09-12 10:03:49Z fabien $ */
  3. class sfRouteCollection implements Iterator
  4. {
  5. protected
  6. $count = 0,
  7. $options = array(),
  8. $routes = array();
  9. /**
  10. * Constructor.
  11. *
  12. * @param array $options An array of options
  13. */
  14. public function __construct(array $options)
  15. {
  16. if (!isset($options['name']))
  17. {
  18. throw new InvalidArgumentException('You must pass a "name" option to sfRouteCollection');
  19. }
  20. $this->options = $options;
  21. }
  22. /**
  23. * Returns the routes.
  24. *
  25. * @return array The routes
  26. */
  27. public function getRoutes()
  28. {
  29. return $this->routes;
  30. }
  31. /**
  32. * Returns the options.
  33. *
  34. * @return array The options
  35. */
  36. public function getOptions()
  37. {
  38. return $this->options;
  39. }
  40. /**
  41. * Reset the error array to the beginning (implements the Iterator interface).
  42. */
  43. public function rewind()
  44. {
  45. reset($this->routes);
  46. $this->count = count($this->routes);
  47. }
  48. /**
  49. * Get the name of the current route (implements the Iterator interface).
  50. *
  51. * @return string The key
  52. */
  53. public function key()
  54. {
  55. return key($this->routes);
  56. }
  57. /**
  58. * Returns the current route (implements the Iterator interface).
  59. *
  60. * @return mixed The escaped value
  61. */
  62. public function current()
  63. {
  64. return current($this->routes);
  65. }
  66. /**
  67. * Moves to the next route (implements the Iterator interface).
  68. */
  69. public function next()
  70. {
  71. next($this->routes);
  72. --$this->count;
  73. }
  74. /**
  75. * Returns true if the current route is valid (implements the Iterator interface).
  76. *
  77. * @return boolean The validity of the current route; true if it is valid
  78. */
  79. public function valid()
  80. {
  81. return $this->count > 0;
  82. }
  83. }

Debug toolbar