123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- namespace Symfony\Component\Routing\Matcher\Dumper;
- class DumperCollection implements \IteratorAggregate
- {
-
- private $parent;
-
- private $children = array();
-
- private $attributes = array();
-
- public function all()
- {
- return $this->children;
- }
-
- public function add($child)
- {
- if ($child instanceof DumperCollection) {
- $child->setParent($this);
- }
- $this->children[] = $child;
- }
-
- public function setAll(array $children)
- {
- foreach ($children as $child) {
- if ($child instanceof DumperCollection) {
- $child->setParent($this);
- }
- }
- $this->children = $children;
- }
-
- public function getIterator()
- {
- return new \ArrayIterator($this->children);
- }
-
- public function getRoot()
- {
- return (null !== $this->parent) ? $this->parent->getRoot() : $this;
- }
-
- protected function getParent()
- {
- return $this->parent;
- }
-
- protected function setParent(DumperCollection $parent)
- {
- $this->parent = $parent;
- }
-
- public function hasAttribute($name)
- {
- return array_key_exists($name, $this->attributes);
- }
-
- public function getAttribute($name, $default = null)
- {
- return $this->hasAttribute($name) ? $this->attributes[$name] : $default;
- }
-
- public function setAttribute($name, $value)
- {
- $this->attributes[$name] = $value;
- }
-
- public function setAttributes($attributes)
- {
- $this->attributes = $attributes;
- }
- }
|