Exemple #1
0
 public function loadConfig(Model\Aop $aop)
 {
     foreach ($this->objectReflectionClass->getMethods() as $reflectionMethod) {
         $annotations = $this->reader->getMethodAnnotations($reflectionMethod);
         $beforeAdvices = [];
         $afterAdvices = [];
         $insteadAdvices = [];
         $canceled = null;
         $group = null;
         switch (get_class($annotation)) {
             case Annotation::After:
                 $afterAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
                 break;
             case Annotation::Before:
                 $beforeAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
                 break;
             case Annotation::Cancel:
                 $canceled = true;
                 break;
             case Annotation::Group:
                 $group = $annotation->id;
                 break;
             case Annotation::Instead:
                 $insteadAdvices[] = new Model\Advice($annotation->context, $annotation->method, $annotation->args);
                 break;
         }
         $method = new Method();
         if (!empty($beforeAdvices)) {
             $method->setBeforeAdvices($beforeAdvices);
         }
         if (!empty($afterAdvices)) {
             $method->setAfterAdvices($afterAdvices);
         }
         if (!empty($insteadAdvices)) {
             $method->setInsteadAdvices($insteadAdvices);
         }
         if (isset($group)) {
             $method->setGroup($group);
         }
         if (isset($canceled)) {
             $method->setCanceled($canceled);
         }
         $aop->addMethod($method);
     }
 }