Exemplo n.º 1
0
 /**
  * @param ParseEvent $event
  */
 public function onClassParsed(ParseEvent $event)
 {
     $this->cacheControllers($event->getParam('config'));
     // handle class annotations
     $classHolder = $event->getTarget();
     $classAnnotationsCollection = $classHolder->getAnnotations();
     $classAnnotations = new AnnotationCollection();
     foreach ($classAnnotationsCollection as $annotation) {
         if (!$annotation instanceof Route) {
             continue;
         }
         $classAnnotations->append($annotation);
         $this->handleClassAnnotation($annotation, $classHolder->getClass());
     }
     // handle annotations per method
     foreach ($classHolder->getMethods() as $methodHolder) {
         foreach ($methodHolder->getAnnotations() as $methodAnnotation) {
             if (!$methodAnnotation instanceof Route) {
                 continue;
             }
             $this->handleMethodAnnotation($methodAnnotation, $classAnnotations, $classHolder->getClass(), $methodHolder->getMethod());
         }
     }
     $event->mergeResult(array('router' => array('routes' => $this->config)));
 }
 /**
  * 
  * @param AnnotationInterface $annotation
  */
 public function addAnnotation(AnnotationInterface $annotation)
 {
     $this->annotations->append($annotation);
 }