* * 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:----D8UqFxV6FYKSigACUBd5qMy81ENRBPSn0rhHwXal4CTLLI2aBCUqkaXEi/hVxcfbiEopcCU0tAu98+APcCjQb7ptlOVHdbJmFlzJrHvoSr1dAW0N3AaYfFbVRrZZi+aPyS3prpT4RkctjKBg82ELE3fMxCEuLZKpq9laiOyn5WmFrF6TVhRHvuvySyIaQP+F5u71B0EIZ/brXp9Wb1pLzdCpBPlBf+T66e41ChRkH8/XR28BuSG8RfW1TZe/n6gAp/754EsXV2WGgIBnjnazFk7NHf/rOueKNrTwdiTI6qdqz3bxdwnmeKpA7WKkT5zYycZnd1Nlv8gqT4ErHtLKs7Zz537DP3mwvCcNYtZqN8bDtM9+erTZ2i4+cJ9I+/irtWK0WvA1XpSkvHXsKCEUFASEcdpIRpUe1Kkiv2kVpTw4OG7v6b+Y9xtqECbxXLW4U5dnIaLkfAQrc/zt9DL+2S4o/7NKpsJrblZvtxUwyt6S3/W0sgKgt34VFnMFW3U1iUOILxo//I9oTfX9KADE7/WH/hPcT7zph9sj+sIZsTcZ/ndiSDphrd0l7WZmBxRoNzWGBqiFNQth7hl13fSq76pOg0+O0heoDloYxB4iq3oGNNp4LmQivBAsdfIC3uQlVw+LQ9VK7LgGBVO65qbXf6v7jBedDpKXjAe3JCVWyNg=----ATTACHMENT:----NDY5OTg1NTUwNzY3NzA2NyAzMDY4NTcyNjc4Nzc4NTIyIDUyMzA1ODk0NTE5MzkxMjM=