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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
EventManagerAwareTrait.php
01 <?php
02 /**
03 * Zend Framework (http://framework.zend.com/)
04 *
05 * @link http://github.com/zendframework/zf2 for the canonical source repository
06 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
07 * @license http://framework.zend.com/license/new-bsd New BSD License
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 * @return mixed
40 */
41 public function setEventManager(EventManagerInterface $events)
42 {
43 $identifiers = array(__CLASS__, get_class($this));
44 if (isset($this->eventIdentifier)) {
45 if ((is_string($this->eventIdentifier))
46 || (is_array($this->eventIdentifier))
47 || ($this->eventIdentifier instanceof Traversable)
48 ) {
49 $identifiers = array_unique(array_merge($identifiers, (array) $this->eventIdentifier));
50 } elseif (is_object($this->eventIdentifier)) {
51 $identifiers[] = $this->eventIdentifier;
52 }
53 // silently ignore invalid eventIdentifier types
54 }
55 $events->setIdentifiers($identifiers);
56 $this->events = $events;
57 if (method_exists($this, 'attachDefaultListeners')) {
58 $this->attachDefaultListeners();
59 }
60 return $this;
61 }
62
63 /**
64 * Retrieve the event manager
65 *
66 * Lazy-loads an EventManager instance if none registered.
67 *
68 * @return EventManagerInterface
69 */
70 public function getEventManager()
71 {
72 if (!$this->events instanceof EventManagerInterface) {
73 $this->setEventManager(new EventManager());
74 }
75 return $this->events;
76 }
77 }
78