Exemple #1
0
 /**
  * Process class annotations
  *
  * @param string $className
  * @param mixed  $instance
  */
 public function processClass($className, $instance = null)
 {
     TypeCheck::doCheck(DataType::STRING);
     $reflector = new \ReflectionClass($className);
     foreach ($this->handlers as $handler) {
         $handler->handleClassAnnotations($reflector, $this->collector->getAnnotationsFor($reflector), $instance);
         foreach ($reflector->getMethods() as $method) {
             $handler->handleMethodAnnotations($method, $this->collector->getAnnotationsFor($method), $instance);
         }
         foreach ($reflector->getProperties() as $property) {
             $handler->handlePropertyAnnotations($property, $this->collector->getAnnotationsFor($property), $instance);
         }
     }
 }
 /**
  * Handle action response
  *
  * @param ControllerResponseEvent $event
  */
 public function onActionResponse(ControllerResponseEvent $event)
 {
     if ($event->getActionResponse() instanceof TwigView) {
         $event->getActionResponse()->setTwig($this->twig);
         return;
     }
     $annotations = $this->annotationCollector->getMethodAnnotations(get_class($event->getController()), $event->getActionName());
     if (isset($annotations['View']) && ($annotations['View'][0] = 'Twig')) {
         if (!isset($annotations['Template'])) {
             return;
         }
         $view = new TwigView($annotations['Template'][0], $event->getActionResponse());
         $view->setTwig($this->twig);
         $event->setActionResponse($view);
     }
 }