Example #1
0
 public static function compile(Application $app)
 {
     $class = get_called_class();
     $instance = new $class($app);
     $reflector = new \ReflectionClass($instance);
     $reader = new Reader();
     $container = $app['controllers_factory'];
     foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
         $annotations = $reader->getMethodAnnotations($method);
         if (isset($annotations->route) && isset($annotations->method)) {
             $route = $annotations->route;
             $httpMethod = strtolower($annotations->method);
             $container->{$httpMethod}($route, $method->getClosure($instance));
         }
     }
     return $container;
 }
Example #2
0
 /**
  * @depends testInitialize
  * @param Reader $reader
  */
 public function testGetMethodAnnotations($reader)
 {
     $reflector = new \ReflectionMethod(__METHOD__);
     $this->assertNotNull($reader->getMethodAnnotations($reflector));
 }