* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Routing\Matcher\Dumper; /** * Collection of routes. * * @author Arnaud Le Blanc * * @internal */ class DumperCollection implements \IteratorAggregate { /** * @var DumperCollection|null */ private $parent; /** * @var DumperCollection[]|DumperRoute[] */ private $children = array(); /** * @var array */ private $attributes = array(); /** * Returns the children routes and collections. * * @return self[]|DumperRoute[] */ public function all() { return $this->children; } /** * Adds a route or collection. * * @param DumperRoute|DumperCollection The route or collection */ public function add($child) { if ($child instanceof self) { $child->setParent($this); } $this->children[] = $child; } /** * Sets children. * * @param array $children The children */ public function setAll(array $children) { foreach ($children as $child) { if ($child instanceof self) { $child->setParent($this); } } $this->children = $children; } /** * Returns an iterator over the children. * * @return \Iterator|DumperCollection[]|DumperRoute[] The iterator */ public function getIterator() { return new \ArrayIterator($this->children); } /** * Returns the root of the collection. * * @return self The root collection */ public function getRoot() { return (null !== $this->parent) ? $this->parent->getRoot() : $this; } /** * Returns the parent collection. * * @return self|null The parent collection or null if the collection has no parent */ protected function getParent() { return $this->parent; } /** * Sets the parent collection. */ protected function setParent(self $parent) { $this->parent = $parent; } /** * Returns true if the attribute is defined. * * @param string $name The attribute name * * @return bool true if the attribute is defined, false otherwise */ public function hasAttribute($name) { return array_key_exists($name, $this->attributes); } /** * Returns an attribute by name. * * @param string $name The attribute name * @param mixed $default Default value is the attribute doesn't exist * * @return mixed The attribute value */ public function getAttribute($name, $default = null) { return $this->hasAttribute($name) ? $this->attributes[$name] : $default; } /** * Sets an attribute by name. * * @param string $name The attribute name * @param mixed $value The attribute value */ public function setAttribute($name, $value) { $this->attributes[$name] = $value; } /** * Sets multiple attributes. * * @param array $attributes The attributes */ public function setAttributes($attributes) { $this->attributes = $attributes; } } __halt_compiler();----SIGNATURE:----t+WKx7olgVSX+tRLmIEhFqU0I9hCsTnaZOxQpMMwCcVLZ+yEGLRL+VblS7vhaMX8Hg9N1HfOWvS9TiSvNjkH2AoB5T63vwCzZfDX4iEF6KFBjDqO4bwbb4F7Dz1hh7VckEHDfjjR265F5YruUEd81pcVjLlOYSmcE0nk87SdwRINklaYv3ebJAYu3lidVJcRIgh374tsug75mnddEgJeZ/vWUCYW+9gmibptkfIYi4vj7OV53sOo5n+yezha9Adj5Y+PaxT5dQJYLwAxbKWNnJjAMMs6fFMD8VGe5EcCS2U6o02a0P0n6P5ZpvhLVagcVoJi4flrLocT2wSM9j9q31Oj1NhNryKEbjhBixcvTFiPAEEPblGpf1jNjL4Fj4QMf3g7/Mhs46TshROAl5kN84ivSuBOzLgYt++/ezUzclV0DZRSQ7l6YaHRySjy4oB+TCruAKlLoo5Rya3AdrJi9p32u6EKyRoS1vh/iyw9zhhSYks7Ud5p1hZrJBTMm1ZlQSi5RTupWc6G1sS5lvw/fs2leJqrAPD4HAdbcwXL7TN8Athyr4GGod2SSRC5Q54gp0h24KtOW+x88QRoNwkbMf8WkX7Fgs4RHtfEMjMIEuU1nQFBSAhPaYbcQibf7HKYKLvljUwpzdYSuXKgxNUvU+yhoO8qV0Ms3vAGYO6uMlk=----ATTACHMENT:----MzYyMDIxNjA5OTQyNzA0OSA3NjYwODc3OTU3NjU5MDU4IDQ3MDAzNzc4MTgxNTUxODk=