Example #1
0
 /**
  * @param type $class
  * @return \Nucleus\IService\Annotation\IParsingResult 
  */
 public function parse($className)
 {
     $reflectionClass = new \ReflectionClass($className);
     $result = new ParsingResult($reflectionClass->getName());
     $result->setClassAnnotations($this->reader->getClassAnnotations($reflectionClass));
     foreach ($reflectionClass->getMethods() as $reflectionMethod) {
         $result->setMethodAnnotations($reflectionMethod->getName(), $this->reader->getMethodAnnotations($reflectionMethod));
     }
     foreach ($reflectionClass->getMethods() as $reflectionMethod) {
         $result->setMethodAnnotations($reflectionMethod->getName(), $this->reader->getMethodAnnotations($reflectionMethod));
     }
     foreach ($reflectionClass->getProperties() as $reflectionProperty) {
         $result->setPropertyAnnotations($reflectionProperty->getName(), $this->reader->getPropertyAnnotations($reflectionProperty));
     }
     $parentClass = $reflectionClass->getParentClass();
     if ($parentClass) {
         $parentResult = $this->parse($parentClass->getName());
         $result->mergeParentClass($parentResult);
     }
     $interfaceClasses = $reflectionClass->getInterfaces();
     foreach ($interfaceClasses as $interfaceClass) {
         /* @var $interfaceClass \ReflectionClass  */
         $interfaceResult = $this->parse($interfaceClass->getName());
         $result->mergeParentClass($interfaceResult);
     }
     return $result;
 }
Example #2
0
 /**
  * Extracts actions from class methods
  * 
  * @param ReflectionClass $class
  * @param AnnotationParsingResult $annotations
  * @return array
  */
 protected function extractActionsFromClass(ReflectionClass $class, AnnotationParsingResult $annotations)
 {
     $actions = array();
     foreach ($annotations->getAllMethodAnnotations() as $methodName => $annos) {
         $actionAnno = null;
         foreach ($annos as $anno) {
             if ($anno instanceof \Nucleus\IService\Dashboard\Action) {
                 // they need to hae the Action annotation
                 $actionAnno = $anno;
                 break;
             }
         }
         if (!$actionAnno) {
             continue;
         }
         $action = $this->buildAction($class->getMethod($methodName), $actionAnno, $annos);
         $prepareMethod = 'prepare' . ucfirst($methodName) . 'Schema';
         if ($class->hasMethod($prepareMethod)) {
             $action = call_user_func(array($class->getName(), $prepareMethod), $action);
         }
         $actions[] = $action;
     }
     return $actions;
 }