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

GenericEvent.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 3.79 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\EventDispatcher;
013   
014  /**
015   * Event encapsulation class.
016   *
017   * Encapsulates events thus decoupling the observer from the subject they encapsulate.
018   *
019   * @author Drak <drak@zikula.org>
020   */
021  class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
022  {
023      /**
024       * Event subject.
025       *
026       * @var mixed usually object or callable
027       */
028      protected $subject;
029   
030      /**
031       * Array of arguments.
032       *
033       * @var array
034       */
035      protected $arguments;
036   
037      /**
038       * Encapsulate an event with $subject and $args.
039       *
040       * @param mixed $subject   The subject of the event, usually an object
041       * @param array $arguments Arguments to store in the event
042       */
043      public function __construct($subject = null, array $arguments = array())
044      {
045          $this->subject = $subject;
046          $this->arguments = $arguments;
047      }
048   
049      /**
050       * Getter for subject property.
051       *
052       * @return mixed $subject The observer subject
053       */
054      public function getSubject()
055      {
056          return $this->subject;
057      }
058   
059      /**
060       * Get argument by key.
061       *
062       * @param string $key Key
063       *
064       * @return mixed Contents of array key
065       *
066       * @throws \InvalidArgumentException If key is not found.
067       */
068      public function getArgument($key)
069      {
070          if ($this->hasArgument($key)) {
071              return $this->arguments[$key];
072          }
073   
074          throw new \InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
075      }
076   
077      /**
078       * Add argument to event.
079       *
080       * @param string $key   Argument name
081       * @param mixed  $value Value
082       *
083       * @return GenericEvent
084       */
085      public function setArgument($key, $value)
086      {
087          $this->arguments[$key] = $value;
088   
089          return $this;
090      }
091   
092      /**
093       * Getter for all arguments.
094       *
095       * @return array
096       */
097      public function getArguments()
098      {
099          return $this->arguments;
100      }
101   
102      /**
103       * Set args property.
104       *
105       * @param array $args Arguments
106       *
107       * @return GenericEvent
108       */
109      public function setArguments(array $args = array())
110      {
111          $this->arguments = $args;
112   
113          return $this;
114      }
115   
116      /**
117       * Has argument.
118       *
119       * @param string $key Key of arguments array
120       *
121       * @return bool
122       */
123      public function hasArgument($key)
124      {
125          return array_key_exists($key, $this->arguments);
126      }
127   
128      /**
129       * ArrayAccess for argument getter.
130       *
131       * @param string $key Array key
132       *
133       * @return mixed
134       *
135       * @throws \InvalidArgumentException If key does not exist in $this->args.
136       */
137      public function offsetGet($key)
138      {
139          return $this->getArgument($key);
140      }
141   
142      /**
143       * ArrayAccess for argument setter.
144       *
145       * @param string $key   Array key to set
146       * @param mixed  $value Value
147       */
148      public function offsetSet($key, $value)
149      {
150          $this->setArgument($key, $value);
151      }
152   
153      /**
154       * ArrayAccess for unset argument.
155       *
156       * @param string $key Array key
157       */
158      public function offsetUnset($key)
159      {
160          if ($this->hasArgument($key)) {
161              unset($this->arguments[$key]);
162          }
163      }
164   
165      /**
166       * ArrayAccess has argument.
167       *
168       * @param string $key Array key
169       *
170       * @return bool
171       */
172      public function offsetExists($key)
173      {
174          return $this->hasArgument($key);
175      }
176   
177      /**
178       * IteratorAggregate for iterating over the object like an array.
179       *
180       * @return \ArrayIterator
181       */
182      public function getIterator()
183      {
184          return new \ArrayIterator($this->arguments);
185      }
186  }
187