예제 #1
0
 /**
  * * @expectedException \ExtDirect\Exceptions\ExtDirectException
  */
 public function testAddNotUnique()
 {
     $method = new Remotable();
     $method->name = "DummyAction";
     $collection = new RemotableCollection();
     $collection->add($method);
     $collection->add($method);
 }
예제 #2
0
 /**
  * checks if given class should be remotable
  *
  * @param string $class the class name to check
  *
  * @return bool|ClassInterface
  * @throws ExtDirectException
  */
 protected function processClass($class)
 {
     if (!class_exists('\\' . $class)) {
         throw new ExtDirectException(" '{$class}' does not exist!");
     }
     $annotationReader = new AnnotationReader();
     AnnotationRegistry::registerLoader('class_exists');
     $reflectionClass = new ReflectionClass($class);
     $classAnnotation = $annotationReader->getClassAnnotation($reflectionClass, 'ExtDirect\\Annotations\\Direct');
     if ($classAnnotation instanceof \ExtDirect\Annotations\Direct) {
         $classAnnotation->setClassName($class);
         $methodCollection = new RemotableCollection();
         foreach ($reflectionClass->getMethods() as $reflectionMethod) {
             $methodAnnotation = $annotationReader->getMethodAnnotation($reflectionMethod, 'ExtDirect\\Annotations\\Remotable');
             if ($methodAnnotation instanceof \ExtDirect\Annotations\Remotable) {
                 $methodAnnotation->setMethodName($reflectionMethod->getName());
                 $methodCollection->add($methodAnnotation);
             }
         }
         $classAnnotation->setMethods($methodCollection);
         return $classAnnotation;
     }
     return false;
 }