本文整理汇总了PHP中Phalcon\Mvc\Router::setDefaultModule方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::setDefaultModule方法的具体用法?PHP Router::setDefaultModule怎么用?PHP Router::setDefaultModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Router
的用法示例。
在下文中一共展示了Router::setDefaultModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerServices
/**
* Register the services here to make them general or register in the ModuleDefinition to make them module-specific
*/
public function registerServices()
{
$di = new FactoryDefault();
$loader = new Loader();
$namespaces = [];
$map = (require_once __DIR__ . '/../autoload_namespaces.php');
foreach ($map as $k => $values) {
$k = trim($k, '\\');
if (!isset($namespaces[$k])) {
$dir = '/' . str_replace('\\', '/', $k) . '/';
$namespaces[$k] = implode($dir . ';', $values) . $dir;
}
}
$loader->registerNamespaces($namespaces);
$loader->register();
/**
* Register a router
*/
$di->set('router', function () {
$router = new Router();
$router->setDefaultModule('frontend');
//set frontend routes
$router->mount(new FrontendRoutes());
//
return $router;
});
$this->setDI($di);
}
示例2: setDi
function setDi()
{
$di = new FactoryDefault();
$di['router'] = function () use($di) {
$router = new Router();
$router->setDefaultModule('mobimall');
return $router;
};
$di['url'] = function () {
$url = new UrlResolver();
$url->setBaseUri('/');
return $url;
};
$di['session'] = function () {
$session = new SessionAdapter();
// $session->start();
return $session;
};
$loader = new Loader();
$loader->registerNamespaces(array('Mall\\Mdu' => __DIR__ . '/../apps/mdu'));
$sysConfig = (include __DIR__ . '/../config/sysconfig.php');
$di['sysconfig'] = function () use($sysConfig) {
return $sysConfig;
};
$loader->register();
return $di;
}
示例3: initRouter
protected function initRouter()
{
$this->getDI()->set('router', function () {
$router = new Router();
$router->setDefaultModule('hrm');
return $router;
});
}
示例4: registerServices
/**
* Register the services here to make them general or register in the ModuleDefinition to make them module-specific
*/
protected function registerServices()
{
$di = new FactoryDefault();
require '../../../autoloader.php';
$loader = new Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(array(__DIR__ . '/../apps/library/'))->register();
$router = new Router();
$router->setDefaultModule("frontend");
//Registering a router
$di->set('router', function () use($router) {
return $router;
});
$this->setDI($di);
}
示例5: registerServices
/**
* Register the services here to make them general or register in the ModuleDefinition to make them module-specific
*/
protected function registerServices()
{
$di = new FactoryDefault();
$loader = new Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(array(__DIR__ . '/../apps/library/'))->register();
//Registering a router
$di->set('router', function () {
$router = new Router();
$router->setDefaultModule("frontend");
$router->add('/:controller/:action', array('module' => 'frontend', 'controller' => 1, 'action' => 2));
$router->add("/login", array('module' => 'backend', 'controller' => 'login', 'action' => 'index'));
$router->add("/admin/products/:action", array('module' => 'backend', 'controller' => 'products', 'action' => 1));
$router->add("/products/:action", array('module' => 'frontend', 'controller' => 'products', 'action' => 1));
return $router;
});
$this->setDI($di);
}
示例6: function
<?php
use Phalcon\Mvc\Router;
/* ==================================================
* ลงทะเบียน "เส้นทางเว็บแอพพลิเคชั่น" (Router)
* Registering a router
* ================================================== */
$config = $this->config;
// Read the configuration
$manager->set('router', function () use($config) {
$router = new Router();
$router->setDefaultModule($config->router->moduleDefault);
$router->setDefaultController($config->router->controllerDefault);
$router->setDefaultAction($config->router->actionDefault);
$router->removeExtraSlashes(TRUE);
$addModule = explode(',', $config->module->moduleLists);
foreach ($addModule as $module) {
$pathModule = APPLICATION_PATH . '/modules/' . $module . '/Router.php';
$nameModule = ucfirst($module) . 'Router';
if (file_exists($pathModule)) {
include_once $pathModule;
$router->mount(new $nameModule($config));
}
}
return $router;
});
示例7: FactoryDefault
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\Di\FactoryDefault;
use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Mvc\Model\Metadata\Memory as MetaDataAdapter;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
/**
* The FactoryDefault Dependency Injector automatically registers the right services to provide a full stack framework
*/
$di = new FactoryDefault();
/**
* Registering a router
*/
$di->setShared('router', function () {
$router = new Router();
$router->setDefaultModule('core');
$router->setDefaultNamespace('Phlame\\Core\\Controllers');
return $router;
});
/**
* The URL component is used to generate all kinds of URLs in the application
*/
$di->setShared('url', function () use($config) {
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
});
/**
* Setting up the view component
*/
//$di->setShared('view', function () use ($config) {
示例8: Router
<?php
use Phalcon\Mvc\Router, Phalcon\Mvc\Router\Group as RouterGroup;
$router = new Router(false);
$router->setDefaultModule(SITENAME);
$router->removeExtraSlashes(true);
$router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);
$router->add('/', array('controller' => 'Index', 'action' => 'index'))->setName('homepage');
$router->add('/testMenu/{store_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Index', 'action' => 'testMenu'))->setName('homepage-test');
$router->add('/menu/ajax/{store_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Index', 'action' => 'menuAjax'))->setName('homepage-ajax');
/*
Orders
*/
$router->add('/order/{order_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Order', 'action' => 'index'))->setName('order');
$router->add('/order/{order_id:[a-z0-9\\-_A-Z]+}/{drink_id:[a-z0-9\\-_A-Z]+}/{coldheat_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Order', 'action' => 'orderDrink'))->setName('order-drink');
$router->add('/order/{order_id:[a-z0-9\\-_A-Z]+}/overview', array('controller' => 'Order', 'action' => 'orderOverview'))->setName('order');
$router->add('/order/add-drink', array('controller' => 'Order', 'action' => 'addDrink'))->setName('order-add-drink');
/*
resouces
*/
$router->add('/resource/stores', array('controller' => 'Resource', 'action' => 'stores'))->setName('resouce-stores');
$router->add('/resource/oStore/{order_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Resource', 'action' => 'orderStore'))->setName('resouce-order-store');
$router->add('/resource/oDrink/{drink_id:[a-z0-9\\-_A-Z]+}/{coldheat_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Resource', 'action' => 'orderDrink'))->setName('resouce-drink-detail');
$router->add('/resource/oDrinkList/{order_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Resource', 'action' => 'orderDrinkList'))->setName('resouce-drink-detail');
$router->add('/order/hook/{store_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Order', 'action' => 'hookOrder'))->setName('order-hook');
$router->notFound(array('controller' => 'Index', 'action' => 'notFound'));
示例9: diRouter
public function diRouter()
{
$di = $this->getDI();
$cachePrefix = $this->getAppName();
$cacheFile = $this->getConfigPath() . "/_cache.{$cachePrefix}.router.php";
if ($router = $this->readCache($cacheFile, true)) {
return $router;
}
$moduleManager = $di->getModuleManager();
$config = new Config();
$moduleName = '';
if ($moduleManager && ($modulesArray = $moduleManager->getModules())) {
foreach ($modulesArray as $moduleName => $module) {
//NOTICE: EvaEngine Load front-end router at last
$config->merge(new Config($moduleManager->getModuleRoutesFrontend($moduleName)));
$config->merge(new Config($moduleManager->getModuleRoutesBackend($moduleName)));
}
}
//Disable default router
$router = new Router(false);
//Last extra slash
$router->removeExtraSlashes(true);
//Set last module as default module
$router->setDefaultModule($moduleName);
//NOTICE: Set a strange controller here to make router not match default index/index
$router->setDefaultController('EvaEngineDefaultController');
$config = $config->toArray();
foreach ($config as $url => $route) {
if (count($route) !== count($route, COUNT_RECURSIVE)) {
if (isset($route['pattern']) && isset($route['paths'])) {
$method = isset($route['httpMethods']) ? $route['httpMethods'] : null;
$router->add($route['pattern'], $route['paths'], $method);
} else {
throw new Exception\RuntimeException(sprintf('No route pattern and paths found by route %s', $url));
}
} else {
$router->add($url, $route);
}
}
if (!$di->getConfig()->debug) {
$this->writeCache($cacheFile, $router, true);
} else {
//Dump merged routers for debug
$this->writeCache($this->getConfigPath() . "/_debug.{$cachePrefix}.router.php", $router, true);
}
return $router;
}
示例10: initRouter
/**
*
* @param type $options
*/
protected function initRouter($options = [])
{
$this->_di->setShared('router', function () {
$router = new Router();
$router->setDefaultModule('intranet');
$router->setDefaultNamespace('Intranet\\Controllers');
$router->removeExtraSlashes(true);
return $router;
});
}
示例11: setDefaultModule
/**
*
*/
public function setDefaultModule($moduleName)
{
parent::setDefaultModule($moduleName);
$this->addStdModule($moduleName);
$this->defaultModule = $moduleName;
}
示例12: Router
<?php
use Phalcon\Mvc\Router;
$router = new Router();
//Remove trailing slashes automatically
$router->removeExtraSlashes(true);
$router->setDefaultModule("backend");
$router->setDefaultNamespace("DigitalKrikits\\Backend\\Controllers");
return $router;
示例13: function
<?php
use Phalcon\Mvc\Router;
$di->set('router', function () use($modules, $defaultModule) {
$router = new Router(false);
/**
* Remove Extra Slashes
* http://docs.phalconphp.com/en/latest/reference/routing.html#dealing-with-extra-trailing-slashes
*/
$router->removeExtraSlashes(true);
/**
* Setting Default Paths
* http://docs.phalconphp.com/en/latest/reference/routing.html#setting-default-paths
*/
if (!empty($defaultModule)) {
$router->setDefaultModule($defaultModule);
}
/**
* Set Default Route
* http://docs.phalconphp.com/en/latest/reference/routing.html#setting-the-default-route
*/
$router->add('/', array('controller' => 'index', 'action' => 'index'));
/**
* Set Not Found Page
* http://docs.phalconphp.com/en/latest/reference/routing.html#not-found-paths
* See [app.config.dispatcher.php]
*/
// $router->notFound(array(
// 'controller' => 'error',
// 'action' => 'e404'
// ));
示例14: initRouter
/**
* Initializes the router
*
* @param array $options
*/
public function initRouter($options = [])
{
$config = $this->di['config'];
$loader = $this->di['loader'];
$this->di->setShared('router', function () use($config, $loader) {
$router = new PhRouter(false);
$router->setDefaultModule('common');
foreach ($config['app_routes'] as $route => $params) {
$router->add($route, (array) $params)->setHostName($config->app_baseUri);
}
if (SUBDOMAIN == 'm') {
$router->setDefaultModule('mobile');
$mobileRoutes = ['/:controller' => ['module' => 'mobile', 'controller' => 1], '/:controller/:action/:params' => ['module' => 'mobile', 'controller' => 1, 'action' => 2, 'params' => 3], '/' => ['module' => 'mobile', 'controller' => 'index', 'action' => 'index']];
foreach ($mobileRoutes as $route => $params) {
$router->add($route, (array) $params)->setHostName('m.' . $config->app_baseUri);
}
}
$router->removeExtraSlashes(true);
return $router;
});
}
示例15: function
* Regitrar Config
*/
$di->set("config", function () use($config) {
return $config;
});
/**
* Registering a router
*/
$di->setShared('router', function () use($config) {
$router = new Router();
//var_dump($config->application->modules);die();
/**
* Include routes
*/
require __DIR__ . '/../config/routes.php';
$router->setDefaultModule('cliente');
$router->setDefaultNamespace('Ticobox\\Cliente\\Controllers');
return $router;
});
/**
* The URL component is used to generate all kinds of URLs in the application
*/
$di->setShared('url', function () use($config) {
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
});
/**
* Setting up the view component
*/
$di->setShared('view', function () use($config) {