本文整理汇总了PHP中Router::routes方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::routes方法的具体用法?PHP Router::routes怎么用?PHP Router::routes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::routes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
// Taken from repos
# The DOC_ROOT and APP_PATH constant have to happen in the actual app
# Document root, ex: /path/to/home/app.com/../ (uses ./ on CLI)
define('DOC_ROOT', empty($_SERVER['DOCUMENT_ROOT']) ? './' : realpath($_SERVER['DOCUMENT_ROOT']) . '/../');
# App path, ex: /path/to/home/app.com/
define('APP_PATH', realpath(dirname(__FILE__)) . '/');
# Environment
require_once DOC_ROOT . 'environment.php';
# Where is core located?
define('CORE_PATH', $_SERVER['DOCUMENT_ROOT'] . "/../core/");
# Load app configs
require APP_PATH . "/config/config.php";
require APP_PATH . "/config/feature_flags.php";
# Bootstrap
require CORE_PATH . "bootstrap.php";
# Routing
Router::$routes = array('/' => '/index');
# Match requested uri to any routes and instantiate controller
Router::init();
# Display environment details
require CORE_PATH . "environment-details.php";
echo "This is the index page";
}
示例2: AddRoute
/**
* Добавить маршрут
* Add Route
*/
public static function AddRoute($route, $destination = null)
{
if ($destination != null && !is_array($route)) {
$route = array($route => $destination);
}
self::$routes = array_merge(self::$routes, $route);
}
示例3: tearDown
/**
* Destroy the test environment
*/
public function tearDown()
{
Config::set('application.url', '');
Config::set('application.index', 'index.php');
Router::$names = array();
Router::$routes = array();
}
示例4: tearDown
/**
* Destroy the test environment.
*/
public function tearDown()
{
// @todo clear httpfoundation request data
Config::set('session.driver', '');
Router::$routes = array();
Router::$names = array();
URL::$base = '';
Config::set('application.index', 'index.php');
Session::$instance = null;
}
示例5: testRoutes
/**
* @covers Zepto\Router::routes()
*/
public function testRoutes()
{
$this->router->get('/get', function () {
return 'This is a get route';
});
$this->router->post('/post', function () {
return 'This is a post route';
});
$routes = $this->router->routes();
$this->assertArrayHasKey('GET', $routes);
$this->assertArrayHasKey('#^/get/$#', $routes['GET']);
$this->assertInstanceOf('Zepto\\Route', $routes['GET']['#^/get/$#']);
$this->assertArrayHasKey('POST', $routes);
$this->assertArrayHasKey('#^/post/$#', $routes['POST']);
$this->assertInstanceOf('Zepto\\Route', $routes['POST']['#^/post/$#']);
}
示例6: start
public static function start()
{
if (!empty($_GET['routes'])) {
$r = $_GET['routes'];
unset($_GET['routes']);
} else {
$r = '';
}
self::$routes = explode('/', $r);
if (count(self::$routes) <= 2) {
self::getCtrlNames();
self::model();
self::controller();
} else {
self::module();
}
}
示例7: testRoutableContentTypes
public function testRoutableContentTypes()
{
$Type = ClassRegistry::init('Taxonomy.Type');
$type = $Type->create(array('title' => 'Press Release', 'alias' => 'press-release', 'description' => ''));
$Type->save($type);
$type = $Type->findByAlias('press-release');
CroogoRouter::routableContentTypes();
$params = array('url' => array(), 'plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'index', 'type' => 'press-release');
$result = Router::reverse($params);
$this->assertEquals('/nodes/nodes/index/type:press-release', $result);
$type['Type']['params'] = 'routes=1';
$Type->save($type);
Router::$routes = array();
CroogoRouter::routableContentTypes();
$result = Router::reverse($params);
$this->assertEquals('/press-release', $result);
}
示例8: initialize
public static function initialize()
{
global $HTTP_RAW_POST_DATA;
global $_PUT;
global $_PST;
self::$routes = SiteStructure::get_routes();
require_once CONFIG . 'routes.php';
self::admin_routes();
// Format PUT/POST data as an associative array
if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
$_PUT = json_decode(file_get_contents('php://input'), TRUE);
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$_PST = json_decode($HTTP_RAW_POST_DATA, TRUE);
foreach ($_POST as $key => $value) {
$_PST[$key] = $value;
}
}
}
示例9: start
public static function start()
{
$r = !empty($_GET['routes']) ? $_GET['routes'] : '';
self::$routes = explode('/', $r);
$params = self::$routes;
unset(self::$params[0], self::$params[1]);
switch (self::$routes[0]) {
case 'module1':
case 'module2':
unset(self::$params[2]);
self::$params = array_values($params);
self::module();
break;
default:
self::$params = array_values($params);
self::getCtrlNames();
self::model();
self::controller();
}
}
示例10: testAddingARoute
public function testAddingARoute()
{
$route = Router::get('/', function () {
});
$this->assertContains($route, Router::routes());
}
示例11:
<?php
namespace NinjaWars\core;
/*
* Adding a default entry helps for when the action is not found or not
* provided, otherwise a 404 will occur.
*/
Router::$routes = ['api' => ['type' => 'controller', 'actions' => ['default' => 'nw_json']], 'signup' => ['type' => 'controller'], 'login' => ['type' => 'controller', 'actions' => ['login_request' => 'requestLogin']], 'clan' => ['type' => 'controller', 'actions' => ['new' => 'create', 'default' => 'listClans', 'list' => 'listClans']], 'list' => ['type' => 'controller', 'actions' => []], 'shop' => ['type' => 'controller', 'actions' => ['purchase' => 'buy']], 'work' => ['type' => 'controller', 'actions' => ['request_work' => 'requestWork']], 'shrine' => ['type' => 'controller', 'actions' => ['heal_and_resurrect' => 'healAndResurrect']], 'doshin' => ['type' => 'controller', 'actions' => ['Bribe' => 'bribe', 'Offer Bounty' => 'offerBounty']], 'duel' => ['type' => 'controller', 'actions' => []], 'stats' => ['type' => 'controller', 'actions' => ['change_details' => 'changeDetails', 'update_profile' => 'updateProfile']], 'npc' => ['type' => 'controller', 'actions' => []], 'events' => ['type' => 'controller', 'actions' => []], 'messages' => ['type' => 'controller', 'actions' => ['delete_clan' => 'deleteClan', 'delete_messages' => 'deletePersonal', 'delete_message' => 'deletePersonal', 'send_clan' => 'sendClan', 'send_personal' => 'sendPersonal', 'personal' => 'viewPersonal', 'message' => 'viewPersonal', 'clan' => 'viewClan', 'default' => 'viewPersonal']], 'account' => ['type' => 'controller', 'actions' => ['show_change_email_form' => 'showChangeEmailForm', 'change_email' => 'changeEmail', 'show_change_password_form' => 'showChangePasswordForm', 'change_password' => 'changePassword', 'show_confirm_delete_form' => 'deleteAccountConfirmation', 'delete_account' => 'deleteAccount']], 'inventory' => ['type' => 'controller', 'actions' => ['use' => 'useItem', 'self_use' => 'selfUse']], 'skill' => ['type' => 'controller', 'actions' => ['use' => 'useSkill', 'self_use' => 'selfUse', 'post_use' => 'postUse', 'post_self_use' => 'postSelfUse']], 'quest' => ['type' => 'controller', 'actions' => []], 'consider' => ['type' => 'controller', 'actions' => ['add' => 'addEnemy', 'delete' => 'deleteEnemy']], 'assistance' => ['type' => 'controller', 'actions' => []], 'password' => ['type' => 'controller', 'actions' => ['post_email' => 'postEmail', 'post_reset' => 'postReset', 'reset' => 'getReset']], 'chat' => ['type' => 'controller', 'actions' => ['receive' => 'receive']], 'map' => ['type' => 'controller', 'actions' => ['view' => 'index']], 'player' => ['type' => 'controller', 'actions' => []], 'news' => ['type' => 'controller', 'actions' => []], 'error' => ['type' => 'controller', 'action' => []], 'rules' => ['type' => 'simple', 'title' => 'Rules'], 'staff' => ['type' => 'simple', 'title' => 'Staff'], 'public' => ['type' => 'simple', 'title' => 'Public Discussion'], 'interview' => ['type' => 'simple', 'title' => 'Interview with John Facey'], 'about' => ['type' => 'simple', 'title' => 'About NinjaWars'], 'intro' => ['type' => 'simple', 'title' => 'Intro to the game']];
Router::$controllerAliases = ['doshin_office' => 'doshin', 'village' => 'chat', 'enemies' => 'consider', 'duel' => 'rumor', 'item' => 'inventory'];
示例12: empty
<?php
# The DOC_ROOT and APP_PATH constant have to happen in the actual app
# Document root, ex: /path/to/home/app.com/../ (uses ./ on CLI)
define('DOC_ROOT', empty($_SERVER['DOCUMENT_ROOT']) ? './' : realpath($_SERVER['DOCUMENT_ROOT']) . '/../');
# App path, ex: /path/to/home/app.com/
define('APP_PATH', realpath(dirname(__FILE__)) . '/');
# Environment
require_once DOC_ROOT . 'environment.php';
# Where is core located?
define('CORE_PATH', $_SERVER['DOCUMENT_ROOT'] . "/../core/");
# Load app configs
require APP_PATH . "/config/config.php";
require APP_PATH . "/config/feature_flags.php";
# Bootstrap
require CORE_PATH . "bootstrap.php";
# Routing
Router::$routes = array('/' => '/index', '/proposal' => '/index/p4');
# Match requested uri to any routes and instantiate controller
Router::init();
# Display environment details
require CORE_PATH . "environment-details.php";
示例13: loadDefaultRoutes
public function loadDefaultRoutes()
{
require CODE_ROOT_DIR . "config/routes.php";
self::$routes = $routes;
}
示例14: setRoutes
public static function setRoutes()
{
self::$routes = explode('/', $_SERVER['REQUEST_URI']);
}
示例15: tearDown
/**
*
*/
public function tearDown()
{
Router::$routes = array();
}