private function mvcRouter() { //Register routing $router = new Router(); $router->clear(); foreach ($this->config('route') as $url => $route) { $router->add($url, $route->toArray()); } return $router; }
/** * @param Router|null $router * @param Url|null $url */ public function __construct(Router $router = null, Url $url = null) { $di = new DI(); $di->setShared('request', new PhalconRequest()); if ($router instanceof PhalconRouterInterface) { $this->router = $router; } elseif ($router === null) { $this->router = new Router(); $this->router->clear(); } else { throw new Exception\RuntimeException('Router has to be an instance of RouterInterface'); } $this->router->setDI($di); $di->setShared('router', $this->router); if ($url instanceof UrlInterface) { $this->url = $url; } elseif ($url === null) { $this->url = new Url(); $this->url->setBaseUri('/'); } else { throw new Exception\RuntimeException('Url has to be an instance of UrlInterface'); } $this->url->setDI($di); }
/** * @return Router */ private static function createPhalconRouter() { $router = new Router(); $router->clear(); $router->setDi(new FactoryDefault()); return $router; }
public function tearDown() { $this->router->clear(); parent::tearDown(); }
<?php use Phalcon\Mvc\Router; $router = new Router(); $router->clear(); $router->removeExtraSlashes(true); // Add default route $router->add("/", array("controller" => "index", "action" => "index")); // Add 404 route $router->notFound(array("controller" => "index", "action" => "index")); // Add route groups $router->mount(new \Pangea\Routes\AccountRoutes()); $router->mount(new \Pangea\Routes\TownRoutes()); $router->mount(new \Pangea\Routes\RaceRoutes()); return $router;
public function clear() { parent::clear(); }