本文整理汇总了PHP中Zend_Controller_Router_Route::chain方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Router_Route::chain方法的具体用法?PHP Zend_Controller_Router_Route::chain怎么用?PHP Zend_Controller_Router_Route::chain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Router_Route
的用法示例。
在下文中一共展示了Zend_Controller_Router_Route::chain方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: routeStartup
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
if (!$this->_issession) {
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
if ($this->_domain) {
$doms = $this->_model->fetchPairs('id', 'domain');
if ($doms) {
foreach ($doms as $k => $el) {
$doms[$k] = @$el[0] ? explode(' ', $el) : array();
}
}
$lang = $request->getParam('lang');
if ($lang) {
$this->_session->lang = $this->_model->fetchOne('id', array('`stitle` = ?' => $lang));
} else {
if ($doms) {
foreach ($doms as $k => $el) {
if (in_array($_SERVER['HTTP_HOST'], $el)) {
$this->_session->lang = $k;
break;
}
}
}
}
$this->_lang = $this->_model->fetchRow(null, '(`id` = ' . (int) $this->_session->lang . ') DESC, (`default` = 1) DESC');
if ($this->_lang) {
$this->_lang = new Zkernel_View_Data($this->_lang);
}
$this->_lang->_default = $this->getDefault();
$this->_lang->_ids = $this->_model->fetchIds();
$this->_lang->_doms = $doms;
} else {
$routes = $router->getRoutes();
$router->removeDefaultRoutes();
if ($routes) {
foreach ($routes as $k => $el) {
$router->removeRoute($k);
}
}
$langRoute = new Zend_Controller_Router_Route(':lang', array('lang' => $this->getDefault()->stitle));
$router->addRoute('default', $langRoute->chain(new Zend_Controller_Router_Route_Module(array(), $front->getDispatcher(), $front->getRequest())));
$router->addRoute('lang', $langRoute);
if ($routes) {
foreach ($routes as $k => $el) {
$router->addRoute($k, $k == 'fu' || $k == 'minify' ? $el : $langRoute->chain($el));
}
}
}
}
$this->save();
}
示例2: init
/**
* Defined by Zend_Application_Resource_Resource
*
* @return Zend_Controller_Router_Rewrite
*/
public function init()
{
if (null === $this->_router) {
$router = $this->getRouter();
// returns $this->_router
$router->addConfig($this->_getConfig());
// add locale chain if using translate
if ($this->getBootstrap()->hasPluginResource('Translate')) {
$locale = new Zend_Controller_Router_Route(':locale', array(), array('locale' => '^[a-z]{2}$'));
$router->addDefaultRoutes();
foreach ($router->getRoutes() as $name => $route) {
//rename existing routes
$router->removeRoute($name)->addRoute($name . 'Default', $route)->addRoute($name, $locale->chain($route));
}
}
}
return $this->_router;
}
示例3: test_RESTfulApp_route_chaining_urlencodedWithPlusSymbol
/**
* @group ZF-10964
*/
public function test_RESTfulApp_route_chaining_urlencodedWithPlusSymbol()
{
$request = $this->_buildRequest('GET', '/api/user/email%2Btest%40example.com');
$this->_front->setRequest($request);
$router = $this->_front->getRouter();
$router->removeDefaultRoutes();
$nonRESTRoute = new Zend_Controller_Router_Route('api');
$RESTRoute = new Zend_Rest_Route($this->_front);
$router->addRoute("api", $nonRESTRoute->chain($RESTRoute));
$routedRequest = $router->route($request);
$this->assertEquals("default", $routedRequest->getParam("module"));
$this->assertEquals("user", $routedRequest->getParam("controller"));
$this->assertEquals("get", $routedRequest->getParam("action"));
$this->assertEquals("email+test@example.com", $routedRequest->getParam("id"));
}
示例4: testChainingWithEmptyStaticRoutesMatchesCorrectly
/**
* @group ZF-7848
*/
public function testChainingWithEmptyStaticRoutesMatchesCorrectly()
{
$adminRoute = new Zend_Controller_Router_Route('admin', array('module' => 'admin', 'controller' => 'index', 'action' => 'index'));
$indexRoute = new Zend_Controller_Router_Route_Static('', array('module' => 'admin', 'controller' => 'index', 'action' => 'index'));
$loginRoute = new Zend_Controller_Router_Route('login', array('module' => 'admin', 'controller' => 'login', 'action' => 'index'));
$emptyRoute = $adminRoute->chain($indexRoute);
$nonEmptyRoute = $adminRoute->chain($loginRoute);
$request = new Zend_Controller_Request_Http();
$request->setPathInfo('/admin');
$values = $emptyRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values);
$request->setPathInfo('/admin/');
$values = $emptyRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values);
$request->setPathInfo('/admin/login');
$values = $nonEmptyRoute->match($request);
$this->assertEquals(array('module' => 'admin', 'controller' => 'login', 'action' => 'index'), $values);
}
示例5: _initRoutes
public function _initRoutes()
{
$this->bootstrap('FrontController');
$this->_frontController = $this->getResource('FrontController');
$router = $this->_frontController->getRouter();
$langRoute = new Zend_Controller_Router_Route(':lang/', array('lang' => 'en'));
$defaultRoute = new Zend_Controller_Router_Route(':controller/:action', array('module' => 'default', 'controller' => 'index', 'action' => 'index'));
$defaultRoute = $langRoute->chain($defaultRoute);
$router->addRoute('langRoute', $langRoute);
$router->addRoute('defaultRoute', $defaultRoute);
}
示例6: testI18nChaining
public function testI18nChaining()
{
$lang = new Zend_Controller_Router_Route(':lang', array('lang' => 'en'));
$profile = new Zend_Controller_Router_Route('user/:id', array('controller' => 'foo', 'action' => 'bar'));
$chain = $lang->chain($profile);
$res = $chain->match(new Zend_Controller_Router_ChainTest_Request('http://localhost/en/user/1'));
$this->assertEquals('en', $res['lang']);
$this->assertEquals('1', $res['id']);
}
示例7: testI18nChaining
public function testI18nChaining()
{
$this->markTestSkipped('Route features not ready');
$lang = new Zend_Controller_Router_Route(':lang', array('lang' => 'en'));
$profile = new Zend_Controller_Router_Route('user/:id', array('controller' => 'foo', 'action' => 'bar'));
$chain = $lang->chain($profile);
$res = $chain->match('en/user/1');
$this->assertEquals('en', $res['lang']);
$this->assertEquals('1', $res['id']);
}