Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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:57 - Dateigröße: 3.54 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   * @internal
 020   */
 021  class DumperCollection implements \IteratorAggregate
 022  {
 023      /**
 024       * @var DumperCollection|null
 025       */
 026      private $parent;
 027   
 028      /**
 029       * @var DumperCollection[]|DumperRoute[]
 030       */
 031      private $children = array();
 032   
 033      /**
 034       * @var array
 035       */
 036      private $attributes = array();
 037   
 038      /**
 039       * Returns the children routes and collections.
 040       *
 041       * @return DumperCollection[]|DumperRoute[] Array of DumperCollection|DumperRoute
 042       */
 043      public function all()
 044      {
 045          return $this->children;
 046      }
 047   
 048      /**
 049       * Adds a route or collection.
 050       *
 051       * @param DumperRoute|DumperCollection The route or collection
 052       */
 053      public function add($child)
 054      {
 055          if ($child instanceof self) {
 056              $child->setParent($this);
 057          }
 058          $this->children[] = $child;
 059      }
 060   
 061      /**
 062       * Sets children.
 063       *
 064       * @param array $children The children
 065       */
 066      public function setAll(array $children)
 067      {
 068          foreach ($children as $child) {
 069              if ($child instanceof self) {
 070                  $child->setParent($this);
 071              }
 072          }
 073          $this->children = $children;
 074      }
 075   
 076      /**
 077       * Returns an iterator over the children.
 078       *
 079       * @return \Iterator|DumperCollection[]|DumperRoute[] The iterator
 080       */
 081      public function getIterator()
 082      {
 083          return new \ArrayIterator($this->children);
 084      }
 085   
 086      /**
 087       * Returns the root of the collection.
 088       *
 089       * @return DumperCollection The root collection
 090       */
 091      public function getRoot()
 092      {
 093          return (null !== $this->parent) ? $this->parent->getRoot() : $this;
 094      }
 095   
 096      /**
 097       * Returns the parent collection.
 098       *
 099       * @return DumperCollection|null The parent collection or null if the collection has no parent
 100       */
 101      protected function getParent()
 102      {
 103          return $this->parent;
 104      }
 105   
 106      /**
 107       * Sets the parent collection.
 108       *
 109       * @param DumperCollection $parent The parent collection
 110       */
 111      protected function setParent(DumperCollection $parent)
 112      {
 113          $this->parent = $parent;
 114      }
 115   
 116      /**
 117       * Returns true if the attribute is defined.
 118       *
 119       * @param string $name The attribute name
 120       *
 121       * @return bool true if the attribute is defined, false otherwise
 122       */
 123      public function hasAttribute($name)
 124      {
 125          return array_key_exists($name, $this->attributes);
 126      }
 127   
 128      /**
 129       * Returns an attribute by name.
 130       *
 131       * @param string $name    The attribute name
 132       * @param mixed  $default Default value is the attribute doesn't exist
 133       *
 134       * @return mixed The attribute value
 135       */
 136      public function getAttribute($name, $default = null)
 137      {
 138          return $this->hasAttribute($name) ? $this->attributes[$name] : $default;
 139      }
 140   
 141      /**
 142       * Sets an attribute by name.
 143       *
 144       * @param string $name  The attribute name
 145       * @param mixed  $value The attribute value
 146       */
 147      public function setAttribute($name, $value)
 148      {
 149          $this->attributes[$name] = $value;
 150      }
 151   
 152      /**
 153       * Sets multiple attributes.
 154       *
 155       * @param array $attributes The attributes
 156       */
 157      public function setAttributes($attributes)
 158      {
 159          $this->attributes = $attributes;
 160      }
 161  }
 162