コード例 #1
0
ファイル: MvcAnnotationDriver.php プロジェクト: im286er/Ding
 /**
  * Will call HttpUrlMapper::addAnnotatedController to add new mappings
  * from the @Controller annotated classes. Also, creates a new bean
  * definition for every one of them.
  *
  * (non-PHPdoc)
  * @see Ding\Bean\Lifecycle.ILifecycleListener::afterConfig()
  */
 public function afterConfig()
 {
     foreach ($this->reflectionFactory->getClassesByAnnotation('controller') as $controller) {
         foreach ($this->_container->getBeansByClass($controller) as $name) {
             $annotations = $this->reflectionFactory->getClassAnnotations($controller);
             if (!$annotations->contains('requestmapping')) {
                 continue;
             }
             $requestMappings = $annotations->getAnnotations('requestmapping');
             foreach ($requestMappings as $map) {
                 if ($map->hasOption('url')) {
                     foreach ($map->getOptionValues('url') as $url) {
                         HttpUrlMapper::addAnnotatedController($url, $name);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Annotation.php プロジェクト: im286er/Ding
 public function getAspects()
 {
     $ret = array();
     $aspectClasses = $this->reflectionFactory->getClassesByAnnotation('aspect');
     foreach ($aspectClasses as $aspectClass) {
         foreach ($this->_knownBeansByClass[$aspectClass] as $beanName) {
             $rClass = $this->reflectionFactory->getClass($aspectClass);
             foreach ($rClass->getMethods() as $rMethod) {
                 $methodName = $rMethod->getName();
                 $annotations = $this->reflectionFactory->getMethodAnnotations($aspectClass, $methodName);
                 if ($annotations->contains('methodinterceptor')) {
                     foreach ($annotations->getAnnotations('methodinterceptor') as $annotation) {
                         $classExpression = $annotation->getOptionSingleValue('class-expression');
                         $expression = $annotation->getOptionSingleValue('expression');
                         $ret[] = $this->_newAspect($beanName, $classExpression, $expression, $methodName, AspectDefinition::ASPECT_METHOD);
                     }
                 }
                 if ($annotations->contains('exceptioninterceptor')) {
                     foreach ($annotations->getAnnotations('exceptioninterceptor') as $annotation) {
                         $classExpression = $annotation->getOptionSingleValue('class-expression');
                         $expression = $annotation->getOptionSingleValue('expression');
                         $ret[] = $this->_newAspect($beanName, $classExpression, $expression, $methodName, AspectDefinition::ASPECT_EXCEPTION);
                     }
                 }
             }
         }
     }
     return $ret;
 }