本文整理汇总了PHP中Router::map方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::map方法的具体用法?PHP Router::map怎么用?PHP Router::map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::map方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defineRoutes
function defineRoutes()
{
// Login route
Router::map('auth_login_frosso', 'sso-login', array('controller' => 'frosso_auth', 'action' => 'login'));
// Admin Route
Router::map('auth_login_frosso_admin', 'admin/login-frosso-config', array('controller' => 'frosso_auth_admin'));
}
示例2: resource
/**
* Resource map
*
* @param string $path
* @param string $namespace
* @param array $excepts
* @throws \InvalidArgumentException
*/
public function resource($path, $namespace, $excepts = array())
{
foreach ($this->injectors['resource'] as $type => $opt) {
if (in_array($type, $excepts)) {
continue;
}
$this->router->map($path . (!empty($opt[1]) ? '/' . $opt[1] : ''), $namespace . '\\' . (!empty($opt[2]) ? $opt[2] : ucfirst($type)), $opt[0]);
}
}
示例3: defineRoutes
function defineRoutes()
{
// Hijacked Route
Router::map('project_tasks', 'projects/:project_slug/tasks', array('controller' => 'frosso_tasks_tab_mod', 'action' => 'index'));
// Single task
// Servono perch� se viene salvato un task tra i preferiti, viene caricata la view dei tasks di default, senza il responsabile
Router::map('project_task', 'projects/:project_slug/tasks/:task_id', array('controller' => 'frosso_tasks_tab_mod', 'action' => 'view'), array('task_id' => Router::MATCH_ID));
Router::map('project_task_edit', 'projects/:project_slug/tasks/:task_id/edit', array('controller' => 'frosso_tasks_tab_mod', 'action' => 'edit'), array('task_id' => Router::MATCH_ID));
Router::map('frosso_tasks_tab_route', 'projects/:project_slug/tasks-old', array('controller' => 'tasks', 'action' => 'index', 'module' => TASKS_MODULE));
}
示例4: testPathForRouteNotExists
/**
* @expectedException \RuntimeException
*/
public function testPathForRouteNotExists()
{
$methods = ['GET'];
$pattern = '/hello/{first}/{last}';
$callable = function ($request, $response, $args) {
echo sprintf('Hello %s %s', $args['first'], $args['last']);
};
$route = $this->router->map($methods, $pattern, $callable);
$route->setName('foo');
$this->router->pathFor('bar', ['first' => 'josh', 'last' => 'lockhart']);
}
示例5: load
public static function load(Router $router, $resource, FileLocator $fileLocator)
{
$path = $fileLocator->locate($resource);
$content = self::loadFile($path);
// empty file
if (null === $content) {
return;
}
foreach ($content as $key => $val) {
$router->map($val["methods"], $val["route"], $val["target"], $key);
}
}
示例6: add
/**
* Adds a new route
* @param string $method The HTTP method (GET/POST)
* @param string $route The route
* @param mixed $title Either the title of the page or a closure (same as $function)
* @param Closure $function The code to run
* @return void
*/
public function add($method, $route, $title, $function = null)
{
if ($function === null) {
$function = $title;
$class = explode('@', $function);
$class_name = $this->framework->getNameSpace() . '\\Controllers\\' . $class[0];
$object = new $class_name($this, $this->framework);
$function = array($object, $class[1]);
$title = null;
}
$name = $this->sanitize_function($route);
$this->routes[$name] = array('method' => strtoupper($method), 'route' => $route, 'title' => $title, 'function' => $function);
$this->router->map(strtoupper($method), $route, $function, $name);
}
示例7: defineRoutes
function defineRoutes()
{
// Reports
Router::map('frosso_estimated_cost_report', 'reports/frosso-ecr', array('controller' => 'frosso_estimated_cost_reports', 'action' => 'index'));
Router::map('frosso_estimated_cost_report_run', 'reports/frosso-ecr-run', array('controller' => 'frosso_estimated_cost_reports', 'action' => 'form_run'));
Router::map('frosso_testing_route', 'reports/frosso-test', array('controller' => 'frosso_testing', 'action' => 'index'));
Router::map('frosso_ec_set_milestone_percent', 'projects/:project_slug/milestones/:milestone_id/percent/set', array('controller' => 'milestones_tracking', 'action' => 'set_percent'));
// Hijacked Routes
Router::map('project_milestones', 'projects/:project_slug/milestones', array('controller' => 'milestones_tracking', 'action' => 'index'));
Router::map('project_milestone', 'projects/:project_slug/milestones/:milestone_id', array('controller' => 'milestones_tracking', 'action' => 'view'), array('milestone_id' => Router::MATCH_ID));
Router::map('project_milestones_add', 'projects/:project_slug/milestones/add', array('controller' => 'milestones_tracking', 'action' => 'add'));
Router::map('project_milestone_edit', 'projects/:project_slug/milestones/:milestone_id/edit', array('controller' => 'milestones_tracking', 'action' => 'edit'), array('milestone_id' => Router::MATCH_ID));
Router::map('project_object_update_milestone', 'projects/:project_slug/objects/:object_id/update-milestone', array('controller' => 'milestones_tracking', 'action' => 'update_milestone'), array('object_id' => Router::MATCH_ID));
// Tracking
if (AngieApplication::isModuleLoaded('tracking')) {
// prefisso, url, nome controller, nome modulo, parametri extra
AngieApplication::getModule('tracking')->defineTrackingRoutesFor('project_milestone', 'projects/:project_slug/milestones/:milestone_id', 'milestones_tracking', FROSSO_EC_MODULE, array('milestone_id' => Router::MATCH_ID));
}
// if
}
示例8: router
/**
* Figure out where the user is trying to get to and route them to the
* appropriate controller/action.
*/
function router()
{
// Create a new Router instance.
$r = new Router();
// Configure the routes, where the user should go when they access the
// specified URL structures. Default controller and action is set in the
// config.php file.
$r->map('/', array('controller' => ROUTER_DEFAULT_CONTROLLER, 'action' => ROUTER_DEFAULT_ACTION));
$r->map('/user', array('controller' => 'user', 'action' => 'index'));
$r->map('/login', array('controller' => 'user', 'action' => 'login'));
$r->map('/logout', array('controller' => 'user', 'action' => 'logout'));
$r->map('/signup', array('controller' => 'user', 'action' => 'register'));
$r->map('/users/:id', array('controller' => 'users'), array('id' => '[\\d]{1,8}'));
// Load instructions for basic routing and send the user on their way!
$r->default_routes();
$r->execute();
// Extracting info about where the user is headed, in order to match the
// URL with the correct controllers/actions.
$controller = $r->controller;
$model = $r->controller_name;
$action = $r->action;
$id = $r->id;
$params = $r->params;
// Returns an array(...)
$matched = $r->route_found;
// Bool, where True is if a route was found.
if ($matched) {
// If going to a site page, treat it in special manner, otherwise load
// the appropriate controller/action and pass in the variables and
// parameters specified by the URL.
if ($controller == "site") {
$site = new Site();
$site->load_page($action);
} elseif (file_exists(LIB_DIR . '/controllers/' . $controller . '.php')) {
${$controller} = new $model();
if (method_exists(${$controller}, $action)) {
${$controller}->{$action}($id, $params[0], $params[1]);
} else {
Site::load_page('error');
}
} else {
Site::load_page('error');
}
} else {
Site::load_page('home');
}
}
示例9: defineRoutes
/**
* Define module routes
*/
function defineRoutes()
{
Router::map('add_git_repository', '/projects/:project_slug/repositories/add-git', array('controller' => 'project_tracking_gitolite', 'action' => 'add_git_repo'));
Router::map('project_repositories', '/projects/:project_slug/repositories', array('controller' => 'project_tracking_gitolite', 'action' => 'index'));
Router::map('repository_history', '/projects/:project_slug/repositories/:project_source_repository_id', array('controller' => 'project_tracking_gitolite', 'action' => 'history'), array('project_source_repository_id' => Router::MATCH_ID));
Router::map('project_project_source_repository', '/projects/:project_slug/repositories/:project_source_repository_id', array('controller' => 'project_tracking_gitolite', 'action' => 'history'), array('project_source_repository_id' => Router::MATCH_ID));
Router::map('get_public_keys', 'people/:company_id/users/:user_id/public-keys', array('controller' => 'ac_gitolite', 'action' => 'getpublickeys'));
Router::map('add_public_keys', 'people/:company_id/users/:user_id/add-public-keys', array('controller' => 'ac_gitolite', 'action' => 'add_public_keys'));
Router::map('remove_key', 'people/:company_id/users/:user_id/delete-keys/:key_id', array('controller' => 'ac_gitolite', 'action' => 'remove_key'));
Router::map('gitolite_admin', 'admin/gitolite_admin', array('controller' => 'ac_gitolite_admin', 'action' => 'index'));
Router::map('gitolite_admin_change', 'admin/change_gitolite_setings', array('controller' => 'ac_gitolite_admin', 'action' => 'gitolite_admin'));
Router::map('gitolite_test_connection', 'admin/test_connection', array('controller' => 'ac_gitolite_admin', 'action' => 'test_connection'));
Router::map('edit_git_repository', '/projects/:project_slug/repositories/:project_source_repository_id/edit-git', array('controller' => 'project_tracking_gitolite', 'action' => 'edit_git_repo'));
Router::map('deleted_gitolite_repo', '/projects/:project_slug/repositories/:project_source_repository_id/delete-repo', array('controller' => 'project_tracking_gitolite', 'action' => 'delete_gitolite_repository'));
Router::map('add_gitolite_steps', '/projects/:project_slug/repositories/:project_source_repository_id/action/:action/params/:params', array('controller' => 'project_tracking_gitolite', 'action' => 'add_git_repo'));
Router::map('delele_repo_url', 'admin/gitolite_admin/delete', array('controller' => 'ac_gitolite_admin', 'action' => 'delete_repo'));
Router::map('need_help_path', 'admin/gitolite_admin/help', array('controller' => 'ac_gitolite_admin', 'action' => 'need_help'));
Router::map('repository_update', '/projects/:project_slug/repositories/:project_source_repository_id/update', array('controller' => 'project_tracking_gitolite', 'action' => 'update'), array('project_source_repository_id' => Router::MATCH_ID));
Router::map('add_remote_git', '/projects/:project_slug/repositories/add-remote-git', array('controller' => 'project_tracking_gitolite', 'action' => 'add_remote_git_repo'));
Router::map('save_admin_settings', 'admin/save_admin_settings', array('controller' => 'ac_gitolite_admin', 'action' => 'save_admin_settings'));
Router::map('check_user_exists', 'admin/check_user_exists', array('controller' => 'ac_gitolite_admin', 'action' => 'check_user_exists'));
Router::map('map_users', 'admin/map_users', array('controller' => 'ac_gitolite_admin', 'action' => 'map_conf_user'));
Router::map('map_repos', 'admin/map_repos', array('controller' => 'ac_gitolite_admin', 'action' => 'map_conf_repos'));
Router::map('render_after_clone', 'admin/render_after_clone', array('controller' => 'ac_gitolite_admin', 'action' => 'render_after_clone_conf'));
Router::map('admin_source', '/admin/tools/source', array('controller' => 'ac_gitolite_source', 'action' => 'index'));
Router::map('admin_source_git_repository_delete', '/admin/tools/source/git-repositories/:source_repository_id/delete-new', array('controller' => 'ac_gitolite_source', 'action' => 'delete_git'), array('source_repository_id' => Router::MATCH_ID));
Router::map('clone_source_git_repository', '/admin/tools/source/clone-gitolite', array('controller' => 'ac_gitolite_source', 'action' => 'clone_source_git_repository'));
Router::map('repository_add_existing', '/projects/:project_slug/repositories/add-existing', array('controller' => 'project_tracking_gitolite', 'action' => 'add_existing'));
Router::map('add_source_gitolite_repository', '/admin/tools/source/add-gitolite-repo', array('controller' => 'ac_gitolite_source', 'action' => 'add_source_gitolite_repository'));
Router::map('add_hooks_git', '/projects/:project_slug/repositories/:project_source_repository_id/add-git-hook', array('controller' => 'project_tracking_gitolite', 'action' => 'add_git_hooks'), array('project_source_repository_id' => Router::MATCH_ID));
Router::map('test_hooks_url', '/projects/:project_slug/repositories/:project_source_repository_id/test-hooks-url', array('controller' => 'project_tracking_gitolite', 'action' => 'test_hooks_url'), array('project_source_repository_id' => Router::MATCH_ID));
Router::map('hookcall', 'hookcall', array('controller' => 'ac_gitolite_hooks', 'action' => 'hooks_call'));
Router::map('add_ftp_conn', '/projects/:project_slug/repositories/:project_source_repository_id/add-ftp-details', array('controller' => 'project_tracking_gitolite', 'action' => 'add_ftp_connections'));
Router::map('test_ftp_conn', '/projects/:project_slug/repositories/:project_source_repository_id/test-ftp-details', array('controller' => 'project_tracking_gitolite', 'action' => 'test_ftp_connection'));
//Router::map('map_repos', '/projects/:project_slug/repositories/map-remote-git', array('controller'=>'project_tracking_gitolite', 'action'=>'map_conf_repos'), array('project_slug'=>Router::MATCH_SLUG));
}
示例10: array
$r->match("/artist/:artist")->to(array("controller" => "application", "action" => "show"))->name("artist");
$r->match("/book(/:id)")->to(array("controller" => "application", "action" => "show"))->name("show_book");
$r->match("/user/profile")->to(array("controller" => "application", "action" => "profile"))->name("user_profile");
$r->match("/app/:action")->to(array("controller" => "application"))->name("app");
$r->match("/app/:action.:format")->to(array("controller" => "application"));
$r->match("/:controller/:action(/:id)")->to();
});
*/
Router::map(function ($r) {
$r->root("/", array("controller" => "application", "action" => "show"));
$r->the_name_format("/the_name/:action.:format", array("controller" => "application"));
$r->api_recent("/api/recent.:format", array("controller" => "application", "action" => "api_recent"));
$r->the_name("/the_name", array("controller" => "application", "action" => "the_name"));
$r->session_set("/artist/session_set", array("controller" => "application", "action" => "session_set"));
$r->redirect("/artist/redirect", array("controller" => "application", "action" => "redirect"));
$r->flash_example("/artist/flash_example", array("controller" => "application", "action" => "flash_example"));
$r->flash_show("/artist/flash_show", array("controller" => "application", "action" => "flash_show"));
$r->my_layout("/artist/my_layout", array("controller" => "application", "action" => "my_layout"));
$r->html_form("/artist/html_form", array("controller" => "application", "action" => "html_form"));
$r->artist("/artist/:artist", array("controller" => "application", "action" => "show"));
$r->show_book("/book(/:id)", array("controller" => "application", "action" => "show"));
$r->user_profile("/user/profile", array("controller" => "application", "action" => "profile"));
$r->app("/app/:action", array("controller" => "application"));
$r->connect("/app/:action.:format", array("controller" => "application"));
$r->connect("/:controller/:action(/:id)");
});
示例11: Router
<?php
require 'Router.php';
require 'Route.php';
$router = new Router();
$router->setBasePath('/PHP-Router');
$router->map('/', 'someController:indexAction', array('methods' => 'GET'));
$router->map('/users/', 'users#create', array('methods' => 'POST', 'name' => 'users_create'));
$router->map('/users/:id/edit/', 'users#edit', array('methods' => 'GET', 'name' => 'users_edit', 'filters' => array('id' => '(\\d+)')));
$router->map('/contact/', array('controller' => 'someController', 'action' => 'contactAction'), array('name' => 'contact'));
$router->map('/blog/:slug', array('c' => 'BlogController', 'a' => 'showAction'));
// capture rest of URL in "path" parameter (including forward slashes)
$router->map('/site-section/:path', 'some#target', array('filters' => array('path' => '(.*)')));
$route = $router->matchCurrentRequest();
?>
<h3>Current URL & HTTP method would route to: </h3>
<?php
if ($route) {
?>
<strong>Target:</strong>
<pre><?php
var_dump($route->getTarget());
?>
</pre>
<strong>Parameters:</strong>
<pre><?php
var_dump($route->getParameters());
?>
</pre>
<?php
示例12: Router
include 'php/fs/dml.flatfs.class.inc.php';
include 'web_framework/router.class.php';
include 'php/reporter.php';
include 'php/mappers/usermapper.php';
include 'php/models/user.class.php';
include 'php/mappers/foldermapper.php';
include 'php/models/folder.class.php';
include 'php/mappers/filemapper.php';
include 'php/models/file.class.php';
/* This is the front-end controller */
$rout_r = new Router();
$rout_r->map('GET', '/', function () {
global $GLOBALS;
session_start();
if (!isset($_SESSION['userID'])) {
$tpl_engine = $GLOBALS['tpl_engine'];
$tpl_engine->__set_filetpl('index.html', NULL);
$tpl_engine->render();
}
header("Location:" . $GLOBALS["url"] . "/control-panel/");
});
$rout_r->map('GET', '/control-panel/', function () {
session_start();
if (isset($_SESSION['userID'])) {
global $GLOBALS;
$tpl_engine = $GLOBALS['tpl_engine'];
$db = new MySqlDAO();
$userMapper = new UserMapper($db);
$user = $userMapper->findById($_SESSION['userID']);
$tpl_engine->__set_filetpl('main.html', array('user' => $user->getUserName()));
$tpl_engine->render();
} else {
示例13: Dataporten
$feide = new Dataporten($feide_config);
// 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');
示例14: Dataporten
$dataporten_config = json_decode(file_get_contents($DATAPORTEN_CONFIG_PATH), true);
$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));
示例15: Router
<?php
$router = new Router();
// create router instance
$router->map('/', array('controller' => 'home'));
// Repositories
// Completed
$router->map('/:project', array('controller' => 'projects', 'action' => 'show', 'branch' => 'master'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/tree', array('controller' => 'projects', 'action' => 'show', 'branch' => 'master'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/tree/:branch', array('controller' => 'projects', 'action' => 'show'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+'));
// Completed
$router->map('/:project/tree/:branch/:filepath', array('controller' => 'projects', 'action' => 'show'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/branch_redirect', array('controller' => 'projects', 'action' => 'branch_redirect'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/commit/:commit', array('controller' => 'commits', 'action' => 'show'), array('project' => '[\\w_-]+(?:\\.git)?', 'commit' => '[\\w]+'));
// Completed
$router->map('/:project/commits', array('controller' => 'commits', 'action' => 'index', 'branch' => 'master'), array('project' => '[\\w_-]+(?:\\.git)?'));
// Completed
$router->map('/:project/commits/:branch', array('controller' => 'commits', 'action' => 'index'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+'));
//Files
$router->map('/:project/blob/:branch/:filepath', array('controller' => 'projects', 'action' => 'blob'), array('project' => '[\\w_-]+(?:\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/raw/:branch/:filepath', array('controller' => 'projects', 'action' => 'raw'), array('project' => '[\\w_-]+(\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/blame/:branch/:filepath', array('controller' => 'projects', 'action' => 'blame'), array('project' => '[\\w_-]+(\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->map('/:project/download/:branch/:filepath', array('controller' => 'projects', 'action' => 'download'), array('project' => '[\\w_-]+(\\.git)?', 'branch' => '[\\w_-]+', 'filepath' => '.*'));
$router->default_routes();
$router->execute();