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


PHP route::match方法代码示例

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


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

示例1: getAllRoutes

 /**
  * get all routes
  * get the URLs, the variables, the modules and the actions of all routes, use the "/applications/config/routes.xml" file.
  * @param string current url (optionnal)
  * @return array list of routes object
  */
 public function getAllRoutes($currentUrl = null)
 {
     //get content of the file.
     $xml = new \DOMDocument();
     $xml->load(__DIR__ . '/../applications/config/routes.xml');
     $file = $xml->getElementsByTagName('route');
     //parse the content.
     $varsNames = array();
     $varsValues = array();
     $varsList = array();
     foreach ($file as $line) {
         //create the route.
         $varsNames = explode(',', $line->getAttribute('vars'));
         //get the name of all variables
         $route = new route($line->getAttribute('url'), $line->getAttribute('module'), $line->getAttribute('action'), $line->getAttribute('name'), $varsNames);
         //get variables.
         if ($varsValues = $route->match($currentUrl)) {
             array_shift($varsValues);
             // the first result contain the full captured string (cf. pregmatch manual).
             foreach ($varsValues as $key => $match) {
                 $varsList[$varsNames[$key]] = $match;
             }
             $route->setVars($varsList);
         }
         //add the route to the router.
         $this->addRoute($route);
     }
     //return all routes.
     return $this->routes;
 }
开发者ID:ThomasSchweizer,项目名称:agoraexmachina,代码行数:36,代码来源:router.class.php

示例2: function

| 后台通用route
|--------------------------------------------------------------------------
*/
route::group(array('prefix' => 'shopadmin'), function () {
    # 系统分类
    route::match(array('GET', 'POST'), '/', array('as' => 'shopadmin', 'uses' => 'desktop_router@dispatch'));
});
/*
|--------------------------------------------------------------------------
| setup
|--------------------------------------------------------------------------
*/
route::group(array('prefix' => 'setup'), function () {
    # 安装首页
    route::match(array('GET', 'POST'), '/', ['as' => 'setup', 'uses' => 'setup_ctl_default@index']);
    # 安装页
    route::match(array('GET', 'POST'), '/default/process', ['uses' => 'setup_ctl_default@process']);
    # 命令行安装
    route::match(array('GET', 'POST'), '/default/install_app', ['uses' => 'setup_ctl_default@install_app']);
    # console
    route::match(array('GET', 'POST'), '/default/console', ['uses' => 'setup_ctl_default@console']);
    # 激活
    route::match(array('GET', 'POST'), '/default/active', ['uses' => 'setup_ctl_default@active']);
    # 激活成功
    route::match(array('GET', 'POST'), '/default/success', ['uses' => 'setup_ctl_default@success']);
    # 环境初始化
    route::match(array('GET', 'POST'), '/default/initenv', ['uses' => 'setup_ctl_default@initenv']);
    # 女装初始化数据
    route::match(array('GET', 'POST'), '/default/install_demodata', ['uses' => 'setup_ctl_default@install_demodata']);
    route::match(array('GET', 'POST'), '/default/setuptools', ['uses' => 'setup_ctl_default@setuptools']);
});
开发者ID:453111208,项目名称:bbc,代码行数:31,代码来源:routes.php


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