Esempio n. 1
0
 public function testSetAndGetAction()
 {
     $route = new Route('GET', '/test/{param1}/{param2}', null);
     $route->setAction(['domain' => 'http://test.com', 'controller' => 'routeController']);
     $this->assertSame('http://test.com', $route->getDomain());
     $this->assertTrue(is_array($route->getAction()));
     $this->assertSame('routeController', $route->getActionName());
     $route->setAction(['controller' => null]);
     $this->assertSame('Closure', $route->getActionName());
 }
Esempio n. 2
0
 /**
  * Create a new route instance.
  *
  * @param array|string $methods
  * @param string       $uri
  * @param mixed        $action
  *
  * @return \Viserio\Contracts\Routing\Route
  */
 protected function createRoute($methods, string $uri, $action) : RouteContract
 {
     // If the route is routing to a controller we will parse the route action into
     // an acceptable array format before registering it and creating this route
     // instance itself. We need to build the Closure that will call this out.
     if ($this->actionReferencesController($action)) {
         $action = $this->convertToControllerAction($action);
     }
     $route = new Route($methods, $this->prefix($uri), $action);
     $route->setContainer($this->getContainer());
     $route->setInvoker($this->getInvoker());
     $this->addWhereClausesToRoute($route);
     return $route;
 }