本文整理汇总了PHP中Router::mapResources方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::mapResources方法的具体用法?PHP Router::mapResources怎么用?PHP Router::mapResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::mapResources方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
* different urls to chosen controllers and their actions (functions).
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CroogoRouter', 'Croogo.Lib');
Router::connect('/signup', array('controller' => 'user', 'action' => 'register'));
Router::connect('/loggout', array('controller' => 'user', 'action' => 'loggout'));
Router::connect('/admin', array('controller' => 'admin', 'action' => 'index'));
Router::connect('/wxapi/*', array('controller' => 'wxapi', 'action' => 'index'));
Router::connect('/admin/wc/*', array('controller' => 'admin', 'action' => 'wc'));
Router::connect('/version', array('controller' => 'user', 'action' => 'version'));
Router::mapResources('users');
Router::mapResources('education');
Router::mapResources('wx');
CakePlugin::routes();
Router::connect('/', array('controller' => 'user', 'action' => 'login'));
Router::parseExtensions('json', 'rss');
CroogoRouter::localize();
require CAKE . 'Config' . DS . 'routes.php';
示例2: array
<?php
Router::mapResources(array('gifts', 'users'));
Router::resourceMap(array(array('action' => 'index', 'method' => 'GET', 'id' => false), array('action' => 'view', 'method' => 'GET', 'id' => true), array('action' => 'add', 'method' => 'POST', 'id' => false), array('action' => 'update', 'method' => 'PUT', 'id' => true), array('action' => 'signup', 'method' => 'POST', 'id' => false), array('action' => 'delete', 'method' => 'DELETE', 'id' => true)));
Router::parseExtensions();
require CAKE . 'Config' . DS . 'routes.php';
示例3: testHttpMethodOverrides
/**
* testHttpMethodOverrides method
*
* @return void
* @triggers DispatcherTest $dispatcher, array('request' => $request)
* @triggers DispatcherTest $dispatcher, array('request' => $request)
* @triggers DispatcherTest $dispatcher, array('request' => $request)
* @triggers DispatcherTest $dispatcher, array('request' => $request)
* @triggers DispatcherTest $dispatcher, array('request' => $request)
*/
public function testHttpMethodOverrides()
{
Router::reload();
Router::mapResources('Posts');
$_SERVER['REQUEST_METHOD'] = 'POST';
$dispatcher = new Dispatcher();
$request = new CakeRequest('/posts');
$event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request));
$dispatcher->parseParams($event);
$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST');
foreach ($expected as $key => $value) {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT';
$request = new CakeRequest('/posts/5');
$event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request));
$dispatcher->parseParams($event);
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT');
foreach ($expected as $key => $value) {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
unset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
$_SERVER['REQUEST_METHOD'] = 'GET';
$request = new CakeRequest('/posts/5');
$event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request));
$dispatcher->parseParams($event);
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '[method]' => 'GET');
foreach ($expected as $key => $value) {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
$_POST['_method'] = 'PUT';
$request = new CakeRequest('/posts/5');
$event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request));
$dispatcher->parseParams($event);
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT');
foreach ($expected as $key => $value) {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
$_POST['_method'] = 'POST';
$_POST['data'] = array('Post' => array('title' => 'New Post'));
$_POST['extra'] = 'data';
$_SERVER = array();
$request = new CakeRequest('/posts');
$event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request));
$dispatcher->parseParams($event);
$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST', 'data' => array('extra' => 'data', 'Post' => array('title' => 'New Post')));
foreach ($expected as $key => $value) {
$this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s');
}
unset($_POST['_method']);
}
示例4: array
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'index'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Create RESTful routes for some controllers...
*/
Router::mapResources('notes');
Router::parseExtensions('json');
/*
Router::connect('/videos/:id/notes',
array('controller' => 'videos', 'action' => 'notes', "[method]" => "GET"),
array('pass' => array('id'))
);
Router::connect('/videos/:id/notes',
array('controller' => 'videos', 'action' => 'notes', "[method]" => "POST"),
array('pass' => array('id'))
);
*/
/**
* Create shortcuts to the installation controller
*/
示例5: array
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
* Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
Router::mapResources(array('posts', 'client'));
Router::parseExtensions('json', 'xml');
require CAKE . 'Config' . DS . 'routes.php';
示例6: array
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
* Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
Router::mapResources('tarefas');
Router::parseExtensions();
require CAKE . 'Config' . DS . 'routes.php';
示例7: testHttpMethodOverrides
/**
* testHttpMethodOverrides method
*
* @access public
* @return void
*/
function testHttpMethodOverrides()
{
Router::reload();
Router::mapResources('Posts');
$_SERVER['REQUEST_METHOD'] = 'POST';
$dispatcher =& new Dispatcher();
$dispatcher->base = false;
$result = $dispatcher->parseParams('/posts');
$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST', 'form' => array(), 'url' => array());
$this->assertEqual($result, $expected);
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT';
$result = $dispatcher->parseParams('/posts/5');
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array());
$this->assertEqual($result, $expected);
unset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = $dispatcher->parseParams('/posts/5');
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'form' => array(), 'url' => array());
$this->assertEqual($result, $expected);
$_POST['_method'] = 'PUT';
$result = $dispatcher->parseParams('/posts/5');
$expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'form' => array(), 'url' => array());
$this->assertEqual($result, $expected);
$_POST['_method'] = 'POST';
$_POST['data'] = array('Post' => array('title' => 'New Post'));
$_POST['extra'] = 'data';
$_SERVER = array();
$result = $dispatcher->parseParams('/posts');
$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST', 'form' => array('extra' => 'data'), 'data' => array('Post' => array('title' => 'New Post')), 'url' => array());
$this->assertEqual($result, $expected);
unset($_POST['_method']);
}
示例8: array
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'Books', 'action' => 'index', 'home'));
// Router::connect('/index', array('controller' => 'Books', 'action' => 'index', 'home'));
// Router::connect('/books/add', array('controller' => 'Books', 'action' => 'add'));
Router::mapResources('books');
Router::mapResources('bets');
Router::mapResources('users');
// Router::connect('/test', array('controller' => 'Books', 'action' => 'test', 'home'));
// Router::connect('/user-rankings', array('controller' => 'Users', 'action' => 'userRankings', 'home'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/update/*', array('controller' => 'updates'));
Router::connect('/users/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/users/facebook_login', array('controller' => 'users', 'action' => 'facebook_login'));
Router::connect('/profile/edit', array('controller' => 'users', 'action' => 'edit'));
Router::connect('/profile/home', array('controller' => 'users', 'action' => 'home'));
Router::connect('/passbooks/*', array('controller' => 'users', 'action' => 'profile', 'passbooks'));
// Router::connect('/profile/*', array('controller' => 'users', 'action' => 'profile','profile'));
Router::connect('/betlists/*', array('controller' => 'users', 'action' => 'profile', 'betlists'));
Router::connect('/makedbooks/*', array('controller' => 'users', 'action' => 'profile', 'makedbooks'));
示例9: array
* Link demo calculo frete da estrutura
* WordPress
*/
CroogoRouter::connect('/calculo/frete.html', array('controller' => 'produtos', 'action' => 'frete'));
/**
* Corrige links de versões antigas como a estrutura
* WordPress
*/
CroogoRouter::connect('/calcular-frete/*', array('controller' => 'urls', 'action' => 'url'));
// Botao calculo frete antigo
CroogoRouter::connect('/frete/*', array('controller' => 'produtos', 'action' => 'frete'));
/**
* BOTOES
* no WordPress existia uma estrutura na raiz
* onde havia o diretório botoes na raiz
*/
CroogoRouter::connect('/botoes/*', array('controller' => 'urls', 'action' => 'botoes'));
/**
* Rastreamento
* Corrige links de versões antigas como a estrutura
* WordPress
*/
//CroogoRouter::connect( '/rastreamento/rastrear-pedido.html', array( 'controller' => 'codigos', 'action' => 'add' ) );
/**
* API Rest
*/
//Router::mapResources( 'Produtos', array('prefix' => '/api/') );
Router::mapResources('Produtos');
Router::mapResources('Codigos');
Router::mapResources('Avisos');
Router::parseExtensions('xml', 'html', 'pdf');
示例10: testResourceRoutes
/**
* testResourceRoutes method
*
* @access public
* @return void
*/
function testResourceRoutes()
{
Router::mapResources('Posts');
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = Router::parse('/posts');
$this->assertEqual($result, array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => 'GET'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = Router::parse('/posts/13');
$this->assertEqual($result, array('pass' => array('13'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'view', 'id' => '13', '[method]' => 'GET'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
$_SERVER['REQUEST_METHOD'] = 'POST';
$result = Router::parse('/posts');
$this->assertEqual($result, array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
$_SERVER['REQUEST_METHOD'] = 'PUT';
$result = Router::parse('/posts/13');
$this->assertEqual($result, array('pass' => array('13'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => '13', '[method]' => 'PUT'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
$result = Router::parse('/posts/475acc39-a328-44d3-95fb-015000000000');
$this->assertEqual($result, array('pass' => array('475acc39-a328-44d3-95fb-015000000000'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => '475acc39-a328-44d3-95fb-015000000000', '[method]' => 'PUT'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
$_SERVER['REQUEST_METHOD'] = 'DELETE';
$result = Router::parse('/posts/13');
$this->assertEqual($result, array('pass' => array('13'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'delete', 'id' => '13', '[method]' => 'DELETE'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = Router::parse('/posts/add');
$this->assertEqual($result, array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'add'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
Router::reload();
Router::mapResources('Posts', array('id' => '[a-z0-9_]+'));
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = Router::parse('/posts/add');
$this->assertEqual($result, array('pass' => array('add'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'view', 'id' => 'add', '[method]' => 'GET'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
$_SERVER['REQUEST_METHOD'] = 'PUT';
$result = Router::parse('/posts/name');
$this->assertEqual($result, array('pass' => array('name'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => 'name', '[method]' => 'PUT'));
$this->assertEqual($this->router->__resourceMapped, array('posts'));
}
示例11: array
<?php
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/views/pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'leads', 'action' => 'index'));
Router::connect('/mobile', array('controller' => 'users', 'action' => 'login', 'plugin' => 'mobile'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::mapResources(array('users', 'acodeounts'));
Router::parseExtensions();
示例12: array
* different URLs to chosen controllers and their actions (functions).
*
* PHP 5
*
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
Router::mapResources("posts");
Router::mapResources("users");
Router::parseExtensions();
/**
* Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
示例13: array
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Chef Router
*/
App::uses("Vendor", "Model");
$vendorModel = new Vendor();
$vendors = $vendorModel->find("all", array("contain" => false));
foreach ($vendors as $v) {
$slug = strtolower($v['Vendor']['name']);
$slug = str_replace(" ", "-", $slug);
Router::connect('/' . $slug, array('controller' => 'Webapp', 'action' => 'chef', $slug));
// echo $slug."\n";
}
// exit;
Router::connect('/', array('controller' => 'Webapp', 'action' => 'home'));
Router::connect('/dev', array('controller' => 'Webapp', 'action' => 'dev'));
Router::mapResources('vendors');
Router::parseExtensions();
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
* Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
示例14: array
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* Rest API aktivieren
*/
Router::mapResources('bookings');
Router::parseExtensions();
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
* Load the CakePHP default routes. Remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';
示例15: array
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Here, we are connecting '/' (base path) to controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, /app/View/Pages/home.ctp)...
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::mapResources('users');
Router::mapResources('customers');
Router::parseExtensions();
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
/**
* Load the CakePHP default routes. Only remove this if you do not want to use
* the built-in default routes.
*/
require CAKE . 'Config' . DS . 'routes.php';