/** * @param \Yaf\Dispatcher $dispatcher * @return \Yaf\Router */ protected function _initRoute(\Yaf\Dispatcher $dispatcher) { if (\Yaf\Registry::get("Config")->routes) { $router = $dispatcher->getRouter(); $router->addConfig(\Yaf\Registry::get("Config")->routes); return $router; } }
/** * 修改路由信息 * @param \Yaf\Dispatcher $dispatcher 分发对象 * @return void */ public function _initRoute(Dispatcher $dispatcher) { // 路由对象 $router = $dispatcher->getRouter(); // 自定义路由协议 $router->addRoute('enyRouter', new Route()); // 路由重写正则 $router->addConfig(new Ini(sprintf("%sroute.ini"))); }
function _initRoute(Dispatcher $dispatcher) { $router = $dispatcher->getRouter(); $api = new Rewrite('/:module/:version/:method/:responseFormat', array('controller' => 'Api', 'action' => 'index')); $apiDefault = new Rewrite('/:method/:responseFormat', array('controller' => 'Api', 'action' => 'index')); /** * 前后端完全分离,前端靠 /env 这个uri中的内容判断线上还是开发环境,前端自己的开发环境有/env这个静态文件(svn中是忽略状态) * * @var \Yaf\Route\Rewrite $env */ $env = new Rewrite('/staticEnv', array('controller' => 'Index', 'action' => 'staticEnv')); $router->addRoute('api', $apiDefault); $router->addRoute('apiDefault', $api); $router->addRoute('staticEnv', $env); $dispatcher->disableView(); }
/** * 修改路由信息 * @param \Yaf\Dispatcher $dispatcher 分发对象 */ public function _initRoute(Dispatcher $dispatcher) { $router = $dispatcher->getRouter(); $routeConfig = new Ini(CONF_PATH . 'route.ini'); $router->addConfig($routeConfig); }
/** * 注册路由 */ public function _initRule(\Yaf\Dispatcher $dispatcher) { /** * 加载路由的配置文件 */ $config = new \Yaf\Config\Ini(APPLICATION_PATH . '/conf/route.ini'); if ($config->routes) { $routeIns = $dispatcher->getRouter(); $routeIns->addConfig($config->routes); } }
/** * Initialize router. * @param \Yaf\Dispatcher $dispatcher * @return void */ public function _initRoute(\Yaf\Dispatcher $dispatcher) { $config = new \Yaf\Config\Ini(APPLICATION_CONFIG_PATH . "/routes.ini"); if (empty($config->routes)) { return; } $dispatcher->config->routes = $config->routes; $dispatcher->getRouter()->addConfig($config->routes); }
/** * 通过派遣器得到默认的路由器 * 主要有以下几种路由协议 * * Yaf\Route_Simple * Yaf\Route_Supervar * Yaf\Route_Static * Yaf\Route_Map * Yaf\Route_Rewrite * Yaf\Route_Regex * * @param \Yaf\Dispatcher $dispatcher */ public function _initRoute(Dispatcher $dispatcher) { // 通过派遣器得到默认的路由器 $router = $dispatcher->getRouter(); if ($this->config->routes) { $routeConfig = new \Yaf\Config\Ini($this->config->routes); $router->addConfig($routeConfig->routes); } }
public function _initRoute(Dispatcher $dispatcher) { $router = $dispatcher->getRouter(); $rest = RegisterRest::initRegister(); $router->addConfig(new Yaf\Config\Simple($rest)); }