class DumperCollection in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/routing/Matcher/Dumper/DumperCollection.php \Symfony\Component\Routing\Matcher\Dumper\DumperCollection
Collection of routes.
@author Arnaud Le Blanc <arnaud.lb@gmail.com>
@internal
Hierarchy
- class \Symfony\Component\Routing\Matcher\Dumper\DumperCollection implements \Symfony\Component\Routing\Matcher\Dumper\IteratorAggregate
Expanded class hierarchy of DumperCollection
2 files declare their use of DumperCollection
- DumperCollectionTest.php in vendor/
symfony/ routing/ Tests/ Matcher/ Dumper/ DumperCollectionTest.php - DumperPrefixCollectionTest.php in vendor/
symfony/ routing/ Tests/ Matcher/ Dumper/ DumperPrefixCollectionTest.php
File
- vendor/
symfony/ routing/ Matcher/ Dumper/ DumperCollection.php, line 21
Namespace
Symfony\Component\Routing\Matcher\DumperView source
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 (DumperCollection|DumperRoute)[] Array of DumperCollection|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 The iterator
*/
public function getIterator() {
return new \ArrayIterator($this->children);
}
/**
* Returns the root of the collection.
*
* @return DumperCollection The root collection
*/
public function getRoot() {
return null !== $this->parent ? $this->parent
->getRoot() : $this;
}
/**
* Returns the parent collection.
*
* @return DumperCollection|null The parent collection or null if the collection has no parent
*/
protected function getParent() {
return $this->parent;
}
/**
* Sets the parent collection.
*
* @param DumperCollection $parent The parent collection
*/
protected function setParent(DumperCollection $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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DumperCollection:: |
private | property | ||
DumperCollection:: |
private | property | ||
DumperCollection:: |
private | property | ||
DumperCollection:: |
public | function | Adds a route or collection. | |
DumperCollection:: |
public | function | Returns the children routes and collections. | |
DumperCollection:: |
public | function | Returns an attribute by name. | |
DumperCollection:: |
public | function | Returns an iterator over the children. | |
DumperCollection:: |
protected | function | Returns the parent collection. | |
DumperCollection:: |
public | function | Returns the root of the collection. | |
DumperCollection:: |
public | function | Returns true if the attribute is defined. | |
DumperCollection:: |
public | function | Sets children. | |
DumperCollection:: |
public | function | Sets an attribute by name. | |
DumperCollection:: |
public | function | Sets multiple attributes. | |
DumperCollection:: |
protected | function | Sets the parent collection. |