getRouteHandler() public method

Gets the callback for the handler of the specified Route
public getRouteHandler ( string $name ) : callable
$name string The description of the handler _:
return callable Returns the callable handler
Ejemplo n.º 1
0
 /**
  * @test
  */
 public function testGetHandler()
 {
     //Application instance is needed to setup container
     $app = new ApiApplication([ApiApplication::SETTING_API_VERSION => '1beta0']);
     $route = $this->getRouteFixture();
     $mdHandleApiVersion = [$app, 'handleApiVersion'];
     $route->addMiddleware($mdHandleApiVersion);
     $handler1 = function ($id) {
     };
     $handler2 = function ($id) {
         return 1;
     };
     $this->assertInternalType('callable', $route->getHandler());
     $route->addDefaults(['controller' => $handler1]);
     $this->assertSame($handler1, $route->getHandler());
     $route->addDefaults($handler2);
     $this->assertSame($handler2, $route->getHandler());
     //AbstractController based handler
     $route->setDefaults(['controller' => $app->getRouteHandler('Admin_Users:get')]);
     $this->assertInternalType('callable', $route->getHandler());
     $this->assertInstanceOf('Scalr\\Api\\Service\\Admin\\V1beta0\\Controller\\Users', $route->getHandler()[0]);
     $this->assertEquals('get', $route->getHandler()[1]);
 }