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 |
AnnotationManager.php
001 <?php
002 /**
003 * Zend Framework (http://framework.zend.com/)
004 *
005 * @link http://github.com/zendframework/zf2 for the canonical source repository
006 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
007 * @license http://framework.zend.com/license/new-bsd New BSD License
008 */
009
010 namespace Zend\Code\Annotation;
011
012 use Zend\Code\Annotation\Parser\ParserInterface;
013 use Zend\EventManager\Event;
014 use Zend\EventManager\EventManager;
015 use Zend\EventManager\EventManagerAwareInterface;
016 use Zend\EventManager\EventManagerInterface;
017
018 /**
019 * Pluggable annotation manager
020 *
021 * Simply composes an EventManager. When createAnnotation() is called, it fires
022 * off an event of the same name, passing it the resolved annotation class, the
023 * annotation content, and the raw annotation string; the first listener to
024 * return an object will halt execution of the event, and that object will be
025 * returned as the annotation.
026 */
027 class AnnotationManager implements EventManagerAwareInterface
028 {
029 const EVENT_CREATE_ANNOTATION = 'createAnnotation';
030
031 /**
032 * @var EventManagerInterface
033 */
034 protected $events;
035
036 /**
037 * Set the event manager instance
038 *
039 * @param EventManagerInterface $events
040 * @return AnnotationManager
041 */
042 public function setEventManager(EventManagerInterface $events)
043 {
044 $events->setIdentifiers(array(
045 __CLASS__,
046 get_class($this),
047 ));
048 $this->events = $events;
049
050 return $this;
051 }
052
053 /**
054 * Retrieve event manager
055 *
056 * Lazy loads an instance if none registered.
057 *
058 * @return EventManagerInterface
059 */
060 public function getEventManager()
061 {
062 if (null === $this->events) {
063 $this->setEventManager(new EventManager());
064 }
065
066 return $this->events;
067 }
068
069 /**
070 * Attach a parser to listen to the createAnnotation event
071 *
072 * @param ParserInterface $parser
073 * @return AnnotationManager
074 */
075 public function attach(ParserInterface $parser)
076 {
077 $this->getEventManager()
078 ->attach(self::EVENT_CREATE_ANNOTATION, array($parser, 'onCreateAnnotation'));
079
080 return $this;
081 }
082
083 /**
084 * Create Annotation
085 *
086 * @param string[] $annotationData
087 * @return false|\stdClass
088 */
089 public function createAnnotation(array $annotationData)
090 {
091 $event = new Event();
092 $event->setName(self::EVENT_CREATE_ANNOTATION);
093 $event->setTarget($this);
094 $event->setParams(array(
095 'class' => $annotationData[0],
096 'content' => $annotationData[1],
097 'raw' => $annotationData[2],
098 ));
099
100 $eventManager = $this->getEventManager();
101 $results = $eventManager->trigger($event, function ($r) {
102 return (is_object($r));
103 });
104
105 $annotation = $results->last();
106
107 return (is_object($annotation) ? $annotation : false);
108 }
109 }
110