Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of the symfony package.
5
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
/**
12
 * sfRouteCollection represents a collection of routes.
13
 *
14
 * @package    symfony
15
 * @subpackage routing
16
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17
 * @version    SVN: $Id: sfRouteCollection.class.php 29491 2010-05-17 13:10:55Z fabien $
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
}