Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

EventManagerAwareTrait.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 2.42 KiB


01  <?php
02  /**
03   * Zend Framework (http://framework.zend.com/)
04   *
05   * @link      http://github.com/zendframework/zend-eventmanager for the canonical source repository
06   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
07   * @license   https://github.com/zendframework/zend-eventmanager/blob/master/LICENSE.md
08   */
09   
10  namespace Zend\EventManager;
11   
12  use Traversable;
13   
14  /**
15   * A trait for objects that provide events.
16   *
17   * If you use this trait in an object, you will probably want to also implement
18   * EventManagerAwareInterface, which will make it so the default initializer in
19   * a ZF2 MVC application will automatically inject an instance of the
20   * EventManager into your object when it is pulled from the ServiceManager.
21   *
22   * @see Zend\Mvc\Service\ServiceManagerConfig
23   */
24  trait EventManagerAwareTrait
25  {
26      /**
27       * @var EventManagerInterface
28       */
29      protected $events;
30   
31      /**
32       * Set the event manager instance used by this context.
33       *
34       * For convenience, this method will also set the class name / LSB name as
35       * identifiers, in addition to any string or array of strings set to the
36       * $this->eventIdentifier property.
37       *
38       * @param  EventManagerInterface $events
39       */
40      public function setEventManager(EventManagerInterface $events)
41      {
42          $identifiers = [__CLASS__, get_class($this)];
43          if (isset($this->eventIdentifier)) {
44              if ((is_string($this->eventIdentifier))
45                  || (is_array($this->eventIdentifier))
46                  || ($this->eventIdentifier instanceof Traversable)
47              ) {
48                  $identifiers = array_unique(array_merge($identifiers, (array) $this->eventIdentifier));
49              } elseif (is_object($this->eventIdentifier)) {
50                  $identifiers[] = $this->eventIdentifier;
51              }
52              // silently ignore invalid eventIdentifier types
53          }
54          $events->setIdentifiers($identifiers);
55          $this->events = $events;
56          if (method_exists($this, 'attachDefaultListeners')) {
57              $this->attachDefaultListeners();
58          }
59      }
60   
61      /**
62       * Retrieve the event manager
63       *
64       * Lazy-loads an EventManager instance if none registered.
65       *
66       * @return EventManagerInterface
67       */
68      public function getEventManager()
69      {
70          if (! $this->events instanceof EventManagerInterface) {
71              $this->setEventManager(new EventManager());
72          }
73          return $this->events;
74      }
75  }
76