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


PHP Router::getRoutes方法代码示例

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


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

示例1: testAddRoute

 public function testAddRoute()
 {
     $router = new Router();
     $route = $this->getMock('Route');
     $router->addRoute('myroute', $route);
     $routes = $router->getRoutes();
     $this->assertTrue(array_key_exists('myroute', $routes));
 }
开发者ID:neurobashing,项目名称:php-router,代码行数:8,代码来源:RouterTest.php

示例2: parseUri

 public static function parseUri($uriToParse)
 {
     $result = array();
     $routes = Router::getRoutes();
     $hasArea = Router::uriHasArea($uriToParse);
     $normalizedUri = Router::normalizeUri($uriToParse);
     $normalizedSplitUri = explode("/", $normalizedUri);
     // try custom routes
     foreach ($routes as $route) {
         if ($hasArea) {
             if (strstr($normalizedUri, "/") !== false) {
                 $normalizedUri = strstr($normalizedUri, "/");
                 $normalizedUri = substr($normalizedUri, 1);
             }
         }
         if (Router::startsWith($normalizedUri, $route["url"])) {
             if ($hasArea) {
                 $result['area'] = $route['area'];
             }
             $result['controller'] = $route['controller'];
             $result['method'] = $route['method'];
             $paramsUri = str_ireplace($route['url'], "", $normalizedUri);
             $params = explode("/", $paramsUri);
             $result['parameters'] = array_filter($params);
             return $result;
         }
     }
     // default route
     if ($hasArea) {
         $result['area'] = $normalizedSplitUri[0];
         $result['controller'] = $normalizedSplitUri[1] . "Controller";
         if (isset($normalizedSplitUri[2])) {
             $result['method'] = $normalizedSplitUri[2];
             $result['parameters'] = array_slice($normalizedSplitUri, 3);
         } else {
             $result['method'] = 'index';
         }
     } else {
         $result['controller'] = $normalizedSplitUri[0] . "Controller";
         if (isset($normalizedSplitUri[1])) {
             $result['method'] = $normalizedSplitUri[1];
             $result['parameters'] = array_slice($normalizedSplitUri, 2);
         } else {
             $result['method'] = 'index';
         }
     }
     return $result;
 }
开发者ID:NVDonchev,项目名称:WebDevelopmentProject,代码行数:48,代码来源:Router.php

示例3: Router

<?php

//spl_autoload_register();
require '../Core/Router.php';
$router = new Router();
$router->add('', ['controller' => 'Home', 'action' => 'index']);
$router->add('posts', ['controller' => 'Posts', 'action' => 'index']);
//$router->add('posts/new', ['controller' => 'Posts', 'action' => 'new']);
$router->add('{controller}/{action}');
$router->add('admin/{controller}/{action}');
$url = $_SERVER['QUERY_STRING'];
if ($router->match($url)) {
    echo '<pre>';
    var_dump($router->getRoutes());
    var_dump($router->getParams());
    echo '</pre>';
} else {
    echo 'no routes found for URL ' . $url;
}
开发者ID:sydorenkovd,项目名称:test-items,代码行数:19,代码来源:index.php

示例4: testInterceptCallToUnknownMethodsAndAddNamedRoute

 public function testInterceptCallToUnknownMethodsAndAddNamedRoute()
 {
     $this->Router->person('person/:name');
     $this->assertEqual(1, count($this->Router->getRoutes()));
     $this->assertEqual(array('person'), array_keys($this->Router->getRoutes()));
 }
开发者ID:bermi,项目名称:akelos,代码行数:6,代码来源:router.php

示例5: Router

//  http://altorouter.com
require_once $BASE . '/lib/router.class.php';
$router = new Router();
// $router->addMatchTypes(array('userlist' => '[0-9A-Za-z\[\]@.,%]++'));
$router->setBasePath($API_BASE_PATH);
// Relay API
require_once $BASE . '/lib/relay.class.php';
$relay_config = json_decode(file_get_contents($RELAY_CONFIG_PATH), true);
$relay = new Relay($relay_config);
// ---------------------- DEFINE ROUTES ----------------------
/**
 * GET all REST routes
 */
$router->map('GET', '/', function () {
    global $router;
    Response::result($router->getRoutes());
}, 'Routes listing');
/**
 * GET TechSmith Relay version
 */
$router->map('GET', '/version/', function () {
    global $relay;
    Response::result($relay->getRelayVersion());
}, 'TechSmith Relay version');
/**
 * GET Template
 *
 * $router->map('GET', '/PATH/[i:iD]/status/', function ($iD) {
 * global $dataporten;
 * Response::result(array('status' => true, 'data' => $dataporten->SOME_FUNCTION($iD)));
 * }, 'DESCRIPTION OF ROUTE');
开发者ID:skrodal,项目名称:relay-fusjonator-api,代码行数:31,代码来源:index.php

示例6: __construct

 /**
  * @param \Rougin\Slytherin\Dispatching\FastRoute\Router $router
  */
 public function __construct(Router $router)
 {
     $this->dispatcher = \FastRoute\simpleDispatcher($router->getRoutes());
     $this->router = $router;
 }
开发者ID:rougin,项目名称:slytherin,代码行数:8,代码来源:Dispatcher.php

示例7: _getSorted

 /**
  * TODO Comments.
  */
 private static function _getSorted()
 {
     if (!self::$_sorted) {
         $routes = Router::getRoutes();
         foreach ($routes as $route => $routeData) {
             if (isset($routeData['permissions']) && $routeData['permissions']) {
                 if (!User::current()->hasPermission($routeData['permissions'])) {
                     continue;
                 }
             }
             $ref =& self::$_sorted;
             $routeBits = explode('/', $route);
             $pathBits = array();
             while ($routeBits) {
                 $bit = array_shift($routeBits);
                 $pathBits[] = $bit;
                 $path = implode('/', $pathBits);
                 if (!isset($ref[$path])) {
                     // For parent routes that dont exist, set a null values
                     $ref[$path] = array('title' => null, 'hidden' => false, 'children' => array());
                     if ($path == $route) {
                         if (isset($routeData['title'])) {
                             $ref[$path]['title'] = $routeData['title'];
                         }
                         if (isset($routeData['hidden'])) {
                             $ref[$path]['hidden'] = $routeData['hidden'];
                         }
                         // Always hide param based items
                         if (strstr($path, '%') || strstr($path, ':')) {
                             $ref[$path]['hidden'] = true;
                         }
                     }
                 }
                 $ref =& $ref[$path]['children'];
             }
         }
     }
     return self::$_sorted;
 }
开发者ID:simudream,项目名称:caffeine,代码行数:42,代码来源:menu.php

示例8: Dataporten

$dataporten = new Dataporten($dataporten_config);
//  http://altorouter.com
require_once $BASE . '/lib/router.class.php';
$router = new Router();
$router->setBasePath($API_BASE_PATH);
// Proxy API to Adobe Connect
require_once $BASE . '/lib/adobeconnect.class.php';
$adobe_config = json_decode(file_get_contents($ADOBE_CONNECT_CONFIG_PATH), true);
$connect = new AdobeConnect($adobe_config);
// ---------------------- DEFINE ROUTES ----------------------
/**
 * GET all REST routes
 */
$router->map('GET', '/', function () {
    global $router;
    Response::result(array('status' => true, 'routes' => $router->getRoutes()));
}, 'Routes listing');
/**
 * GET Adobe Connect version
 */
$router->map('GET', '/version/', function () {
    global $connect;
    Response::result($connect->getConnectVersion());
}, 'Adobe Connect version');
/**
 * Get all subfolders for Shared Meetings/{$orgFolderName}
 */
$router->map('GET', '/folder/[a:org]/nav/', function ($orgFolderName) {
    verifyOrgAccess($orgFolderName);
    global $connect;
    Response::result($connect->getOrgFolderNav($orgFolderName));
开发者ID:skrodal,项目名称:ac-csv-import-api,代码行数:31,代码来源:index.php


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