本文整理汇总了PHP中Zend_Controller_Router_Rewrite::addConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Router_Rewrite::addConfig方法的具体用法?PHP Zend_Controller_Router_Rewrite::addConfig怎么用?PHP Zend_Controller_Router_Rewrite::addConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Router_Rewrite
的用法示例。
在下文中一共展示了Zend_Controller_Router_Rewrite::addConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRouter
/**
* 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;
}
示例2: getRouter
/**
* 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;
}
示例3: _initRouter
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);
}
示例4: setUp
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()));
}
示例5: _initRouter
/**
* 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);
}
示例6: _initRewrite
/**
*
* 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);
}
示例7: _initRoutes
/**
* 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;
}
示例8: _initLoadRouter
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);
}
示例9: _initRouter
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);
}
示例10: recentAction
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);
}
示例11: _addRoutesFromConfig
/**
* 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']);
}
示例12: _initFrontController
/**
* 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'));
}
}
示例13: testChainingWithConfiguredEmptyStaticRoutesMatchesCorrectly
/**
* @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);
}
示例14: array
<?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();
示例15: catch
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);