* * 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:----AXVQ6kTcj0HEmU6qEEEtFgLBfdoXEczz3/wJh6zKR8UB/ilCQGy9u2SARYRFaBjpkWQ6QXfkoX9suRXCXCKtxIW7Tv/aDDNU9Kr2A7G/x61U2IDsQ2c1PbfGUetPs9ZwsZudnibT2NT3EE7UHubz2dBCLJoxp7Ox38Ww86fxVnOmAuqs90GeLd6F6XnunK2Z1d+vSaWMV9dy+rGa5co2qTY0C8ERSroWcZh0O3ZnP95FrUDtJaq7AIw99Oacu/Xs+/nVWqkb3Wh3UT497lZUTjFoVzqimC87O9WhCZ2RT4dwlbikkD1rrP4fNjar2DR2vsGcrLZlqyEk7lIYYj+Nnuc+Tgla1UqEv3bZyLDqND8N0Z8C6oztEXq2OMQ6GXyk7bKQNYVfPYPzSNVvMUPYIkJO3S2ljZ3Roxo5cOZUaEk/yOI5FnqXrX7xtusSXstlkNx+GPtUJjHKPBhX0q3GVZcaBJqN3ABFXAtBQHzV1CyGqKm1wyzviKxN2QAX9vaA9EuvqMsi1VZBLGJgmmqr50Ft2ST61FVTREs8tZnb31dIiP2Ze43OR7SXa16CRRcrRHLbxkF+/KyTZ/JAEux3262F9aci004TmLJzszvmeKH0I4oS9LQGGr4b9GRhOzFuY1BKIblUA71PNuRakIG8QuxLdgQAGikm8LiuBxwG5ck=----ATTACHMENT:----Mzk0NzI2Mzk1NDc4NzUzIDIwMzg3MzE0MDUwNjI2NTEgNzA2MzcyMDA1NzIzOTA3Nw==