本文整理汇总了PHP中core\Router::findRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::findRoute方法的具体用法?PHP Router::findRoute怎么用?PHP Router::findRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core\Router
的用法示例。
在下文中一共展示了Router::findRoute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFindMultipleRoutes
public function testFindMultipleRoutes()
{
$r = new Router($this->container);
$r->addRoute('a/b', 'controller1', 'action1');
$r->addRoute('a/b', 'duplicate', 'duplicate');
$r->addRoute('a', 'controller2', 'action2');
$this->assertEquals(array('controller1', 'action1'), $r->findRoute('a/b'));
$this->assertEquals(array('controller2', 'action2'), $r->findRoute('a'));
}
示例2: run
/**
* Run a project
*/
public function run()
{
$cmv = array('controller' => $this->config->get('defaultController'), 'method' => $this->config->get('defaultMethod'), 'vars' => array());
$_uri = new URI();
$_uri->_fetch_uri_string();
$path = (string) $_uri;
if (!empty($path)) {
$founded = $this->router->findRoute($path);
if (!empty($founded)) {
$cmv = $founded;
} else {
//append uri parts as variables for method invocation
$cmv['vars'] = explode('/', $path);
}
}
//must be defined before view->render, sorry for hardcode
if (DRAGON_DEBUG) {
header('X-Dragon-Debug: ' . Dragon::$host . 'tmp/debug/last.html');
}
//finally we have something to show
$this->loadController($cmv);
$this->view->render();
DebugGenerator::generate();
}