Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

DumperCollection.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 3.52 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\Routing\Matcher\Dumper;
013   
014  /**
015   * Collection of routes.
016   *
017   * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
018   */
019  class DumperCollection implements \IteratorAggregate
020  {
021      /**
022       * @var DumperCollection|null
023       */
024      private $parent;
025   
026      /**
027       * @var (DumperCollection|DumperRoute)[]
028       */
029      private $children = array();
030   
031      /**
032       * @var array
033       */
034      private $attributes = array();
035   
036      /**
037       * Returns the children routes and collections.
038       *
039       * @return (DumperCollection|DumperRoute)[] Array of DumperCollection|DumperRoute
040       */
041      public function all()
042      {
043          return $this->children;
044      }
045   
046      /**
047       * Adds a route or collection
048       *
049       * @param DumperRoute|DumperCollection The route or collection
050       */
051      public function add($child)
052      {
053          if ($child instanceof DumperCollection) {
054              $child->setParent($this);
055          }
056          $this->children[] = $child;
057      }
058   
059      /**
060       * Sets children.
061       *
062       * @param array $children The children
063       */
064      public function setAll(array $children)
065      {
066          foreach ($children as $child) {
067              if ($child instanceof DumperCollection) {
068                  $child->setParent($this);
069              }
070          }
071          $this->children = $children;
072      }
073   
074      /**
075       * Returns an iterator over the children.
076       *
077       * @return \Iterator The iterator
078       */
079      public function getIterator()
080      {
081          return new \ArrayIterator($this->children);
082      }
083   
084      /**
085       * Returns the root of the collection.
086       *
087       * @return DumperCollection The root collection
088       */
089      public function getRoot()
090      {
091          return (null !== $this->parent) ? $this->parent->getRoot() : $this;
092      }
093   
094      /**
095       * Returns the parent collection.
096       *
097       * @return DumperCollection|null The parent collection or null if the collection has no parent
098       */
099      protected function getParent()
100      {
101          return $this->parent;
102      }
103   
104      /**
105       * Sets the parent collection.
106       *
107       * @param DumperCollection $parent The parent collection
108       */
109      protected function setParent(DumperCollection $parent)
110      {
111          $this->parent = $parent;
112      }
113   
114      /**
115       * Returns true if the attribute is defined.
116       *
117       * @param string $name The attribute name
118       *
119       * @return bool    true if the attribute is defined, false otherwise
120       */
121      public function hasAttribute($name)
122      {
123          return array_key_exists($name, $this->attributes);
124      }
125   
126      /**
127       * Returns an attribute by name.
128       *
129       * @param string $name    The attribute name
130       * @param mixed  $default Default value is the attribute doesn't exist
131       *
132       * @return mixed The attribute value
133       */
134      public function getAttribute($name, $default = null)
135      {
136          return $this->hasAttribute($name) ? $this->attributes[$name] : $default;
137      }
138   
139      /**
140       * Sets an attribute by name.
141       *
142       * @param string $name  The attribute name
143       * @param mixed  $value The attribute value
144       */
145      public function setAttribute($name, $value)
146      {
147          $this->attributes[$name] = $value;
148      }
149   
150      /**
151       * Sets multiple attributes.
152       *
153       * @param array $attributes The attributes
154       */
155      public function setAttributes($attributes)
156      {
157          $this->attributes = $attributes;
158      }
159  }
160