/** * Retrieve router object * * @return Zend_Controller_Router_Rewrite */ public function getRouter() { if (null === $this->_router) { $bootstrap = $this->getBootstrap(); $bootstrap->bootstrap('FrontController'); $this->_router = $bootstrap->getContainer()->frontcontroller->getRouter(); $options = $this->getOptions(); if (!isset($options['routes'])) { $options['routes'] = array(); } if (isset($options['chainNameSeparator'])) { $this->_router->setChainNameSeparator($options['chainNameSeparator']); } if (isset($options['useRequestParametersAsGlobal'])) { $this->_router->useRequestParametersAsGlobal($options['useRequestParametersAsGlobal']); } $this->_router->addConfig(new Zend_Config($options['routes'])); } return $this->_router; }
/** * Retrieve router object * * @return Zend_Controller_Router_Rewrite */ public function getRouter() { if (null === $this->_router) { $bootstrap = $this->getBootstrap(); $bootstrap->bootstrap('FrontController'); $front = $bootstrap->getContainer()->frontcontroller; $options = $this->getOptions(); if (!isset($options['routes'])) { $options['routes'] = array(); } $this->_router = $front->getRouter(); $this->_router->addConfig(new Zend_Config($options['routes'])); } return $this->_router; }
protected function _initRouter() { $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini'); $router = new Zend_Controller_Router_Rewrite(); $router->addConfig($config); Zend_Controller_Front::getInstance()->setRouter($router); }
protected function setUp() { parent::setUp(); foreach (array_keys($_POST) as $key) { unset($_POST[$key]); } Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_NonPersistent()); $this->clean(); $front = Zend_Controller_Front::getInstance(); $router = new Zend_Controller_Router_Rewrite(); $routes_config = new USVN_Config_Ini(USVN_ROUTES_CONFIG_FILE, USVN_CONFIG_SECTION); $router->addConfig($routes_config, 'routes'); $front->setRouter($router); $table = new USVN_Db_Table_Users(); $this->user = $table->fetchNew(); $this->user->setFromArray(array('users_login' => 'john', 'users_password' => 'pinocchio')); $this->user->save(); $this->admin_user = $table->fetchNew(); $this->admin_user->setFromArray(array('users_login' => 'god', 'users_password' => 'ingodwetrust', 'users_is_admin' => true)); $this->admin_user->save(); $authAdapter = new USVN_Auth_Adapter_Database('john', 'pinocchio'); Zend_Auth::getInstance()->authenticate($authAdapter); $front->setControllerDirectory(USVN_CONTROLLERS_DIR); $this->request = new USVN_Controller_Request_Http(); $front->setRequest($this->request); $this->response = new Zend_Controller_Response_Cli(); $front->setResponse($this->response); $router->addRoute('default', new Zend_Controller_Router_Route_Module(array(), $front->getDispatcher(), $front->getRequest())); }
/** * Initialize the routes * * @return void */ protected function _initRouter() { $routes = new Zend_Config_Xml(APPLICATION_PATH . '/configs/frontend_routes.xml'); $router = new Zend_Controller_Router_Rewrite(); $router->addConfig($routes); $front = Zend_Controller_Front::getInstance(); $front->setRouter($router); }
/** * * Initialize router */ protected function _initRewrite() { $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production'); $objRouter = new Zend_Controller_Router_Rewrite(); $router = $objRouter->addConfig($config, 'routes'); $front = Zend_Controller_Front::getInstance(); $front->setRouter($router); }
/** * Initialize router * * @return \Zend_Controller_Router_Rewrite */ protected function _initRoutes() { $config = new Zend_Config_Json(APPLICATION_PATH . '/configs/routes/en.json', 'routes', array('ignore_constants' => true, 'skip_extends' => true)); $router = new Zend_Controller_Router_Rewrite(); $router->addConfig($config); $front = Zend_Controller_Front::getInstance(); $front->setRouter($router); return $router; }
protected function _initLoadRouter() { $config = new Zend_Config_Ini(CONFIG_PATH . '/routers.ini', 'setup-router'); $objRouter = new Zend_Controller_Router_Rewrite(); //new Zend_Controller_Router_Route_Regex() $router = $objRouter->addConfig($config, 'routers'); $front = Zend_Controller_Front::getInstance(); $front->setRouter($router); }
protected function _initRouter() { // Loads routes from specific config file $front = $this->bootstrap('FrontController')->getResource('FrontController'); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production'); $routing = new Zend_Controller_Router_Rewrite(); $routing->addConfig($config, 'routes'); $front->setRouter($routing); }
public function recentAction() { //@todo route: do it the right way! $router = new Zend_Controller_Router_Rewrite(); $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini'); $router->addConfig($routeConfig, 'routes'); $registry = Zend_Registry::getInstance(); $config = $registry->get("config"); $this->_helper->verifyIdentity(); $recent = new Ml_Model_Recent(); if (!$registry->isRegistered("authedUserInfo")) { throw new Exception("Not authenticated."); } $userInfo = $registry->get("authedUserInfo"); $uploads = $recent->contactsUploads($userInfo['id']); //send response $doc = new Ml_Model_Dom(); $doc->formatOutput = true; $rootElement = $doc->createElement("items"); $doc->appendChild($rootElement); foreach ($uploads as $share) { $shareElement = $doc->createElement("item"); $avatarInfo = unserialize($share['people.avatarInfo']); if (isset($avatarInfo['secret'])) { $iconSecret = $avatarInfo['secret']; } else { $iconSecret = ''; } $shareData = array("type" => "file", "id" => $share['id']); foreach ($shareData as $name => $field) { $shareElement->appendChild($doc->newTextAttribute($name, $field)); } $shareData = array("title" => $share['share.title'], "short" => $share['share.short'], "url" => "http://" . $config['webhost'] . $router->assemble(array("username" => $share['people.alias'], "share_id" => $share['id']), "sharepage_1stpage")); foreach ($shareData as $name => $field) { $shareElement->appendChild($doc->newTextElement($name, $field)); } $filesizeElement = $doc->createElement("filesize"); $filesizeElement->appendChild($doc->newTextAttribute("bits", $share['share.fileSize'])); $filesizeElement->appendChild($doc->newTextAttribute("kbytes", ceil($share['share.fileSize'] / (1024 * 8)))); $shareElement->appendChild($filesizeElement); $ownerElement = $doc->createElement("owner"); $shareData = array("id" => $share['people.id'], "alias" => $share['people.alias'], "realname" => $share['people.name'], "iconsecret" => $iconSecret); foreach ($shareData as $name => $field) { $ownerElement->appendChild($doc->newTextAttribute($name, $field)); } $shareElement->appendChild($ownerElement); $rootElement->appendChild($shareElement); } $this->_helper->printResponse($doc); }
/** * Add routes from options created from application.ini. * Router resource cannot be declared in module.ini. * * @param array $options | from application.ini */ private function _addRoutesFromConfig($options) { if (!isset($options['resources']['router']['routes'])) { $options['resources']['router']['routes'] = array(); } if (isset($options['resources']['router']['chainNameSeparator'])) { $this->_router->setChainNameSeparator($options['resources']['router']['chainNameSeparator']); } if (isset($options['resources']['router']['useRequestParametersAsGlobal'])) { $this->_router->useRequestParametersAsGlobal($options['resources']['router']['useRequestParametersAsGlobal']); } $this->_router->addConfig(new Zend_Config($options['resources']['router']['routes'])); // don't trigger Zend_Application_Resource_Router unset($options['resources']['router']); }
public function test_getInstance_fromINIConfig() { $config = new \Zend\Config\Ini(dirname(__FILE__) . '/../Controller/_files/routes.ini', 'testing'); $router = new \Zend_Controller_Router_Rewrite(); $router->addConfig($config, 'routes'); $route = $router->getRoute('rest'); $this->assertType('Zend\\REST\\Route', $route); $this->assertEquals('object', $route->getDefault('controller')); $request = $this->_buildRequest('GET', '/mod/project'); $values = $this->_invokeRouteMatch($request, array(), $route); $this->assertEquals('mod', $values['module']); $this->assertEquals('project', $values['controller']); $this->assertEquals('index', $values['action']); $request = $this->_buildRequest('POST', '/mod/user'); $values = $this->_invokeRouteMatch($request, array(), $route); $this->assertEquals('mod', $values['module']); $this->assertEquals('user', $values['controller']); $this->assertEquals('post', $values['action']); $request = $this->_buildRequest('GET', '/other'); $values = $this->_invokeRouteMatch($request, array(), $route); $this->assertFalse($values); }
/** * Router rewrite Front * * @return string url */ protected function _initFrontController() { $url = $_SERVER['REQUEST_URI']; $arr = explode('/', $url); $total_arr = sizeof($arr); $urlCheck = 3; //localhost = 3 server = 2, $arr[1] $detail = $total_arr == $urlCheck && preg_match('/^\\d+-\\d+-.*+$/', $arr[2], $matches) ? true : false; if ($total_arr == $urlCheck && !empty($arr[2]) && !$detail) { $front = Zend_Controller_Front::getInstance(); $front->setControllerDirectory(array('default' => APPLICATION_PATH . "/modules/front/controllers", 'admin' => APPLICATION_PATH . "/modules/admin/controllers")); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routers.ini', 'estore'); $router = new Zend_Controller_Router_Rewrite(); return $front->setRouter($router->addConfig($config, 'routes')); } else { $front = Zend_Controller_Front::getInstance(); $front->setControllerDirectory(array('default' => APPLICATION_PATH . "/modules/front/controllers", 'admin' => APPLICATION_PATH . "/modules/admin/controllers")); $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routers.ini', 'rewriteshopname'); $router = new Zend_Controller_Router_Rewrite(); return $front->setRouter($router->addConfig($config, 'routes')); } }
/** * @group ZF-7848 */ public function testChainingWithConfiguredEmptyStaticRoutesMatchesCorrectly() { $routes = array('admin' => array('route' => 'admin', 'defaults' => array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), 'chains' => array('index' => array('type' => 'Zend_Controller_Router_Route_Static', 'route' => '', 'defaults' => array('module' => 'admin', 'controller' => 'index', 'action' => 'index')), 'login' => array('route' => 'login', 'defaults' => array('module' => 'admin', 'controller' => 'login', 'action' => 'index'))))); $config = new Zend_Config($routes); $rewrite = new Zend_Controller_Router_Rewrite(); $rewrite->addConfig($config); $routes = $rewrite->getRoutes(); $indexRoute = $rewrite->getRoute('admin-index'); $loginRoute = $rewrite->getRoute('admin-login'); $request = new Zend_Controller_Request_Http(); $request->setPathInfo('/admin'); $values = $indexRoute->match($request); $this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values); $request->setPathInfo('/admin/'); $values = $indexRoute->match($request); $this->assertEquals(array('module' => 'admin', 'controller' => 'index', 'action' => 'index'), $values); $request->setPathInfo('/admin/login'); $values = $loginRoute->match($request); $this->assertEquals(array('module' => 'admin', 'controller' => 'login', 'action' => 'index'), $values); }
<?php error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 0); date_default_timezone_set('America/New_York'); $app_path = "../app/"; set_include_path('.' . PATH_SEPARATOR . $app_path . 'libs/ZendFramework-1.11.2/library/' . PATH_SEPARATOR . get_include_path()); require_once 'Zend/Loader.php'; require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); $config = new Zend_Config_Ini($app_path . "config.ini", "path"); require_once $config->smarty . 'Smarty.class.php'; require_once $config->views . 'Zend_View_Smarty.class.php'; require_once $config->common . "common_util.php"; Zend_Session::setOptions(); Zend_Session::start(); $device_type = common_util::check_device(); $config_route = new Zend_Config_Ini($app_path . "config.ini", "routing"); $router = new Zend_Controller_Router_Rewrite(); $router->addConfig($config_route, 'routes'); $frontController = Zend_Controller_Front::getInstance(); $frontController->throwExceptions(true); $frontController->setControllerDirectory($app_path . '/controllers'); $frontController->setParam('useDefaultControllerAlways', true); $frontController->setRouter($router); $view = new Zend_View_Smarty($config->views . 'templates', array('compile_dir' => $config->views . 'templates_c', 'config_dir' => $config->views . 'configs', 'cache_dir' => $config->views . 'cache')); $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setView($view)->setViewBasePathSpec($view->getEngine()->template_dir)->setViewScriptPathSpec(':controller/' . $device_type . '_' . ':action.:suffix')->setViewScriptPathNoControllerSpec($device_type . '_' . ':action.:suffix')->setViewSuffix('html'); $frontController->dispatch();
USVN_Update::runUpdate(); } } catch (Exception $e) { header('Location: install.php'); // echo '<pre>' . "\n"; // echo $e; // echo '</pre>' . "\n"; // exit(0); } /* USVN Configuration */ date_default_timezone_set($config->timezone); USVN_ConsoleUtils::setLocale($config->system->locale); USVN_Translation::initTranslation($config->translation->locale, USVN_LOCALE_DIR); USVN_Template::initTemplate($config->template->name, USVN_MEDIAS_DIR); /* Zend Configuration */ Zend_Registry::set('config', $config); Zend_Db_Table::setDefaultAdapter(Zend_Db::factory($config->database->adapterName, $config->database->options->toArray())); if (isset($config->database->prefix)) { USVN_Db_Table::$prefix = $config->database->prefix; } $front = Zend_Controller_Front::getInstance(); Zend_Layout::startMvc(array('layoutPath' => USVN_LAYOUTS_DIR)); $front->setRequest(new USVN_Controller_Request_Http()); $front->throwExceptions(true); $front->setBaseUrl($config->url->base); /* Initialize router */ $router = new Zend_Controller_Router_Rewrite(); $routes_config = new USVN_Config_Ini(USVN_ROUTES_CONFIG_FILE, USVN_CONFIG_SECTION); $router->addConfig($routes_config, 'routes'); $front->setRouter($router); $front->setControllerDirectory(USVN_CONTROLLERS_DIR);
public function infoAction() { //@todo route: do it the right way! $router = new Zend_Controller_Router_Rewrite(); $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini'); $router->addConfig($routeConfig, 'routes'); $registry = Zend_Registry::getInstance(); $config = $registry->get("config"); $request = $this->getRequest(); $params = $request->getParams(); $people = Ml_Model_People::getInstance(); $favorites = Ml_Model_Favorites::getInstance(); $comments = Ml_Model_Comments::getInstance(); $tags = Ml_Model_Tags::getInstance(); $numbers = new Ml_Model_Numbers(); $this->_helper->loadApiresource->share(); $shareInfo = $registry->get("shareInfo"); $userInfo = $people->getById($shareInfo['byUid']); $tagsList = $tags->getShareTags($shareInfo['id']); $countFavs = $favorites->count($shareInfo['id']); $countComments = $comments->count($shareInfo['id']); //begin of response $doc = new Ml_Model_Dom(); $doc->formatOutput = true; $rootElement = $doc->createElement("file"); $doc->appendChild($rootElement); $rootElement->appendChild($doc->newTextAttribute('id', $shareInfo['id'])); $rootElement->appendChild($doc->newTextAttribute('secret', $shareInfo['secret'])); $rootElement->appendChild($doc->newTextAttribute('download_secret', $shareInfo['download_secret'])); $ownerElement = $doc->createElement("owner"); $ownerData = array("id" => $userInfo['id'], "username" => $userInfo['alias'], "realname" => $userInfo['name']); foreach ($ownerData as $field => $data) { $ownerElement->appendChild($doc->newTextAttribute($field, $data)); } $rootElement->appendChild($ownerElement); $shareData = array("title" => $shareInfo['title'], "filename" => $shareInfo['filename'], "filetype" => $shareInfo['type'], "short" => $shareInfo['short'], "description" => $shareInfo['description_filtered'], "url" => "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias'], "share_id" => $shareInfo['id']), "sharepage_1stpage"), "dataurl" => $config['services']['S3']['sharesBucketAddress'] . $userInfo['alias'] . "/" . $shareInfo['id'] . "-" . $shareInfo['download_secret'] . "/" . $shareInfo['filename'], "shorturl" => $config['URLshortening']['addr'] . $numbers->base58Encode($shareInfo['id']), "comments" => $countComments, "favorites" => $countFavs); foreach ($shareData as $field => $data) { $rootElement->appendChild($doc->newTextElement($field, $data)); } $filesizeElement = $doc->createElement("filesize"); $filesizeElement->appendChild($doc->newTextAttribute("bits", $shareInfo['fileSize'])); $filesizeElement->appendChild($doc->newTextAttribute("kbytes", ceil($shareInfo['fileSize'] / (1024 * 8)))); $rootElement->appendChild($filesizeElement); $checksumElement = $doc->createElement("checksum"); $checksumElement->appendChild($doc->newTextAttribute("hash", "md5")); $checksumElement->appendChild($doc->newTextAttribute("value", $shareInfo['md5'])); $rootElement->appendChild($checksumElement); $visibilityElement = $doc->createElement("visibility"); $visibilityElement->appendChild($doc->newTextAttribute("ispublic", "1")); $rootElement->appendChild($visibilityElement); $datesData = array("posted" => $shareInfo['uploadedTime'], "lastupdate" => $shareInfo['lastChange']); $datesElement = $doc->createElement("dates"); foreach ($datesData as $field => $data) { $datesElement->appendChild($doc->newTextAttribute($field, $data)); } $rootElement->appendChild($datesElement); $tagsElement = $doc->createElement("tags"); foreach ($tagsList as $tag) { $tagElement = $doc->createElement("tag"); $tagElement->appendChild($doc->newTextAttribute("id", $tag['id'])); $tagElement->appendChild($doc->newTextAttribute("raw", $tag['raw'])); $tagElement->appendChild($doc->createTextNode($tag['clean'])); $tagsElement->appendChild($tagElement); } $rootElement->appendChild($tagsElement); $this->_helper->printResponse($doc); }
public function infoAction() { //@todo route: do it the right way! $router = new Zend_Controller_Router_Rewrite(); $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini'); $router->addConfig($routeConfig, 'routes'); $registry = Zend_Registry::getInstance(); $config = $registry->get("config"); $request = $this->getRequest(); $params = $request->getParams(); $people = Ml_Model_People::getInstance(); $profile = Ml_Model_Profile::getInstance(); $share = Ml_Model_Share::getInstance(); if (isset($params['username'])) { $userInfo = $people->getByUsername($params['username']); } else { if (isset($params['user_id'])) { $userInfo = $people->getById($params['user_id']); } else { if (isset($params['email'])) { $userInfo = $people->getByEmail($params['email']); if (!empty($userInfo) && $userInfo['private_email'] == true) { $registry->set("notfound", true); throw new Exception("User not found."); } } else { throw new Exception("No user params were given."); } } } if (empty($userInfo)) { $registry->set("notfound", true); throw new Exception("User not found."); } $profileInfo = $profile->getById($userInfo['id']); $doc = new Ml_Model_Dom(); $doc->formatOutput = true; $rootElement = $doc->createElement("person"); $doc->appendChild($rootElement); $rootElement->appendChild($doc->newTextAttribute('id', $userInfo['id'])); $avatarInfo = unserialize($userInfo['avatarInfo']); if (isset($avatarInfo['secret'])) { $iconSecret = $avatarInfo['secret']; } else { $iconSecret = ''; } $rootElement->appendChild($doc->newTextAttribute('iconsecret', $iconSecret)); $userData = array("username" => $userInfo['alias'], "realname" => $userInfo['name']); if (!$userInfo['private_email']) { $userData["mbox_sha1sum"] = sha1("mailto:" . $userInfo['email']); } $userData["location"] = $profileInfo['location']; $userData["url"] = "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias']), "filestream_1stpage"); foreach ($userData as $field => $data) { $rootElement->appendChild($doc->newTextElement($field, $data)); } $sharesCounter = $share->countOfUser($userInfo['id']); $sharesElement = $doc->createElement("files"); $sharesCounterElement = $doc->createElement("count"); $sharesCounterElement->appendChild($doc->createTextNode($sharesCounter)); $sharesElement->appendChild($sharesCounterElement); $rootElement->appendChild($sharesElement); $this->_helper->printResponse($doc); }
/** * Initialize the routes * * @return void */ protected function _initRouter() { $router = new Zend_Controller_Router_Rewrite(); $routes = new Zend_Config_Xml(APPLICATION_PATH . '/configs/' . CURRENT_MODULE . '_routes.xml'); $router->addConfig($routes); $front = Zend_Controller_Front::getInstance(); $front->setRouter($router); Zend_Registry::set('Router', $router); }
/** * Add router * * @param Zend_Controller_Router_Rewrite $router * @param mixed $config Config * @access public * @return Gene_Application_Setting_Routing Fluent interface */ public function add(Zend_Controller_Router_Rewrite $router, $config = null) { if (is_null($config)) { $config = $this->_config; } if (is_null($config)) { return; } $router->addConfig($config); $this->_router = $router; return $this; }
// Suppressed error if (error_reporting() === 0) { return; } throw new ErrorException($errstr, 0, $severity, $errfile, $errline); } } set_error_handler('exceptions_error_handler'); // **** Timezone date_default_timezone_set('UTC'); if (isset($config->timezone)) { @date_default_timezone_set($config->timezone); } // **** Database if (isset($config->database)) { Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Db::factory($config->database)); } // **** Layout Zend_Layout::startMvc(array('layout' => 'default', 'layoutPath' => LOCAMORE_AP_PATH . '/views/layouts', 'mvcSuccessfulActionOnly' => true)); // **** Routes $router = new Zend_Controller_Router_Rewrite(); if (isset($config->routes)) { $router->addConfig($config->routes); } Zend_Controller_Action_HelperBroker::addPrefix('Locamore_Helper'); $front = Zend_Controller_Front::getInstance(); if (isset($config->baseurl)) { // **** Base URL $front->setBaseUrl($config->baseurl); } $front->setRouter($router)->setControllerDirectory(LOCAMORE_AP_PATH . '/controllers')->setParam('useDefaultControllerAlways', true)->dispatch();
public function testConfigChaining() { $routes = array('www' => array('type' => 'Zend_Controller_Router_Route_Hostname', 'route' => 'www.example.com', 'abstract' => true), 'user' => array('type' => 'Zend_Controller_Router_Route_Hostname', 'route' => 'user.example.com', 'abstract' => true), 'index' => array('type' => 'Zend_Controller_Router_Route_Static', 'route' => '', 'abstract' => true, 'defaults' => array('module' => 'default', 'controller' => 'index', 'action' => 'index')), 'imprint' => array('type' => 'Zend_Controller_Router_Route_Static', 'route' => 'imprint', 'abstract' => true, 'defaults' => array('module' => 'default', 'controller' => 'index', 'action' => 'imprint')), 'profile' => array('type' => 'Zend_Controller_Router_Route_Static', 'route' => 'profile', 'abstract' => true, 'defaults' => array('module' => 'user', 'controller' => 'profile', 'action' => 'index')), 'profile-edit' => array('type' => 'Zend_Controller_Router_Route_Static', 'route' => 'profile/edit', 'abstract' => true, 'defaults' => array('module' => 'user', 'controller' => 'profile', 'action' => 'edit')), 'www-index' => array('type' => 'Zend_Controller_Router_Route_Chain', 'chain' => 'www, index'), 'www-imprint' => array('type' => 'Zend_Controller_Router_Route_Chain', 'chain' => 'www, imprint'), 'user-index' => array('type' => 'Zend_Controller_Router_Route_Chain', 'chain' => 'user, index'), 'user-profile' => array('type' => 'Zend_Controller_Router_Route_Chain', 'chain' => 'user, profile'), 'user-profile-edit' => array('type' => 'Zend_Controller_Router_Route_Chain', 'chain' => 'user, profile-edit')); $router = new Zend_Controller_Router_Rewrite(); $front = Zend_Controller_Front::getInstance(); $front->resetInstance(); $front->setDispatcher(new Zend_Controller_Router_RewriteTest_Dispatcher()); $front->setRequest(new Zend_Controller_Router_RewriteTest_Request()); $router->setFrontController($front); $router->addConfig(new Zend_Config($routes)); $request = new Zend_Controller_Router_ChainTest_Request('http://user.example.com/profile'); $token = $router->route($request); $this->assertEquals('user', $token->getModuleName()); $this->assertEquals('profile', $token->getControllerName()); $this->assertEquals('index', $token->getActionName()); $request = new Zend_Controller_Router_ChainTest_Request('http://foo.example.com/imprint'); $token = $router->route($request); $this->assertEquals('default', $token->getModuleName()); $this->assertEquals('imprint', $token->getControllerName()); $this->assertEquals('defact', $token->getActionName()); }