当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::setDefaultController方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\Router::setDefaultController方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::setDefaultController方法的具体用法?PHP Router::setDefaultController怎么用?PHP Router::setDefaultController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\Router的用法示例。


在下文中一共展示了Router::setDefaultController方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Router

<?php

use Phalcon\Mvc\Router;
$router = new Router();
//$router = new Router(false);
$router->removeExtraSlashes(true);
// 移除URL多余的斜杠
//$router->setUriSource(Router::URI_SOURCE_GET_URL);
$router->setDefaultController('index');
$router->setDefaultAction('index');
$router->setDefaultModule('frontend');
$router->setDefaultNamespace('Apps\\Frontend\\Controllers');
// APP API
$router->add('/appApi', ['module' => 'appApi', 'namespace' => 'Apps\\AppApi\\Controllers\\', 'controller' => 'index', 'action' => 'index']);
$router->add('/appApi' . '/:action', ['module' => 'appApi', 'namespace' => 'Apps\\AppApi\\Controllers\\', 'controller' => 'index', 'action' => 1]);
$defaultController = 'index';
$defaultAction = 'index';
$urlBase = ['/backend' => ['module' => 'backend', 'namespace' => 'Apps\\Backend\\Controllers\\'], '/manage' => ['module' => 'manage', 'namespace' => 'Apps\\Manage\\Controllers\\'], '/frontend' => ['module' => 'frontend', 'namespace' => 'Apps\\Frontend\\Controllers\\'], '/pay' => ['module' => 'pay', 'namespace' => 'Apps\\Pay\\Controllers\\']];
foreach ($urlBase as $k => $v) {
    $module = $v['module'];
    $namespace = $v['namespace'];
    $router->add($k . '/:params', ['module' => $module, 'namespace' => $namespace, 'controller' => $defaultController, 'action' => $defaultAction, 'params' => 1]);
    $router->add($k . '/:controller/:params', ['module' => $module, 'namespace' => $namespace, 'controller' => 1, 'action' => $defaultAction, 'params' => 2]);
    $router->add($k . '/:controller/:action/:params', ['module' => $module, 'namespace' => $namespace, 'controller' => 1, 'action' => 2, 'params' => 3]);
}
return $router;
开发者ID:fu-tao,项目名称:meelier_c,代码行数:26,代码来源:routers.php

示例2: 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;
 }
开发者ID:hushibing,项目名称:EvaEngine,代码行数:47,代码来源:Engine.php

示例3: 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;
});
开发者ID:phalcon-id,项目名称:phalcon2-rest-api,代码行数:26,代码来源:routers.php

示例4: setDefaultController

 public function setDefaultController($controllerName)
 {
     return parent::setDefaultController($controllerName);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Router.php


注:本文中的Phalcon\Mvc\Router::setDefaultController方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。