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


PHP Router::setDefaultModule方法代码示例

本文整理汇总了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);
 }
开发者ID:adrianeavaz,项目名称:manager.io,代码行数:31,代码来源:Application.php

示例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;
}
开发者ID:nicklos17,项目名称:littlemall,代码行数:27,代码来源:index.php

示例3: initRouter

 protected function initRouter()
 {
     $this->getDI()->set('router', function () {
         $router = new Router();
         $router->setDefaultModule('hrm');
         return $router;
     });
 }
开发者ID:adrianeavaz,项目名称:manager.io,代码行数:8,代码来源:Application.php

示例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);
 }
开发者ID:silverwolfx10,项目名称:tcc-uhealth,代码行数:20,代码来源:index.php

示例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);
 }
开发者ID:boiler256,项目名称:mvc,代码行数:23,代码来源:index.php

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

示例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) {
开发者ID:Oscailte,项目名称:phlame,代码行数:31,代码来源:services.php

示例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'));
开发者ID:inno-v,项目名称:LinInLiao,代码行数:26,代码来源:Frontend.php

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

示例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;
     });
 }
开发者ID:denners777,项目名称:api-phalcon,代码行数:14,代码来源:bootstrap.php

示例11: setDefaultModule

 /**
  *
  */
 public function setDefaultModule($moduleName)
 {
     parent::setDefaultModule($moduleName);
     $this->addStdModule($moduleName);
     $this->defaultModule = $moduleName;
 }
开发者ID:JanOschii,项目名称:webird,代码行数:9,代码来源:Router.php

示例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;
开发者ID:vikilaboy,项目名称:digitalkrikits,代码行数:9,代码来源:routes.php

示例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'
    // ));
开发者ID:vfeitoza,项目名称:phalcon-multi-module-skeleton,代码行数:31,代码来源:routes.php

示例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;
     });
 }
开发者ID:aisuhua,项目名称:phalcon-jumpstart,代码行数:26,代码来源:Bootstrap.php

示例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) {
开发者ID:zedmaster,项目名称:ticobox,代码行数:31,代码来源:services.php


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