resourceMap() public static method

Resource map getter & setter.
See also: Router::$_resourceMap
public static resourceMap ( array $resourceMap = null ) : mixed
$resourceMap array Resource map
return mixed
<?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';
Example #2
0
 * different URLs to chosen controllers and their actions (functions).
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * 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
 */
Router::resourceMap(array(array('action' => 'index', 'method' => 'GET', 'id' => false, 'ext' => 'json'), array('action' => 'view', 'method' => 'GET', 'id' => true), array('action' => 'index', 'method' => 'POST', 'id' => false), array('action' => 'edit', 'method' => 'PUT', 'id' => true), array('action' => 'delete', 'method' => 'DELETE', 'id' => true), array('action' => 'add', 'method' => 'POST', 'id' => true)));
Router::mapResources('aliases', array('id' => '[^/]*'));
Router::parseExtensions('xml', 'json');
/**
 * 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.
Example #3
0
 /**
  * Tests resourceMap as getter and setter.
  *
  * @return void
  */
 public function testResourceMap()
 {
     $default = Router::resourceMap();
     $exepcted = array(array('action' => 'index', 'method' => 'GET', 'id' => false), array('action' => 'view', 'method' => 'GET', 'id' => true), array('action' => 'add', 'method' => 'POST', 'id' => false), array('action' => 'edit', 'method' => 'PUT', 'id' => true), array('action' => 'delete', 'method' => 'DELETE', 'id' => true), array('action' => 'edit', 'method' => 'POST', 'id' => true));
     $this->assertEquals($default, $exepcted);
     $custom = array(array('action' => 'index', 'method' => 'GET', 'id' => false), array('action' => 'view', 'method' => 'GET', 'id' => true), array('action' => 'add', 'method' => 'POST', 'id' => false), array('action' => 'edit', 'method' => 'PUT', 'id' => true), array('action' => 'delete', 'method' => 'DELETE', 'id' => true), array('action' => 'update', 'method' => 'POST', 'id' => true));
     Router::resourceMap($custom);
     $this->assertEquals($custom, Router::resourceMap());
     Router::resourceMap($default);
 }
Example #4
0
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * 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
 */
Router::resourceMap();
Router::parseExtensions('json', 'xml');
/**
 * 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' => 'login', 'action' => 'login'));
Router::connect('/register/*', array('controller' => 'register', 'action' => 'register'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/json/index/*', ['controller' => 'posts', 'action' => 'index']);
Router::connect('/json/register/*', ['controller' => 'posts', 'action' => 'register']);
/**
Example #5
0
 * @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();
/**
 * Configure REST API
 */
Router::resourceMap(array(array('controller' => 'products', 'action' => 'view', 'method' => 'GET', 'id' => false), array('controller' => 'products', 'action' => 'search', 'method' => 'GET', 'id' => false), array('controller' => 'products', 'action' => 'order', 'method' => 'POST', 'id' => false)));
Router::mapResources('products');
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';
Example #6
0
 /**
  * Tests resourceMap as getter and setter.
  *
  * @return void
  */
 public function testResourceMap()
 {
     $default = Router::resourceMap();
     $expected = array(array('action' => 'index', 'method' => 'GET', 'id' => FALSE), array('action' => 'view', 'method' => 'GET', 'id' => TRUE), array('action' => 'add', 'method' => 'POST', 'id' => FALSE), array('action' => 'edit', 'method' => 'PUT', 'id' => TRUE), array('action' => 'delete', 'method' => 'DELETE', 'id' => TRUE), array('action' => 'edit', 'method' => 'POST', 'id' => TRUE));
     $this->assertEquals($expected, $default);
     $custom = array(array('action' => 'index', 'method' => 'GET', 'id' => FALSE), array('action' => 'view', 'method' => 'GET', 'id' => TRUE), array('action' => 'add', 'method' => 'POST', 'id' => FALSE), array('action' => 'edit', 'method' => 'PUT', 'id' => TRUE), array('action' => 'delete', 'method' => 'DELETE', 'id' => TRUE), array('action' => 'update', 'method' => 'POST', 'id' => TRUE));
     Router::resourceMap($custom);
     $this->assertEquals(Router::resourceMap(), $custom);
     Router::resourceMap($default);
 }
<?php

Router::connect('/api/:version/login', array('plugin' => 'Oxicode', 'controller' => 'Rest', 'action' => 'login', 'ext' => 'json'), array('version' => '1'));
Router::connect('/api/:version/:noun/*', array('plugin' => 'Oxicode', 'controller' => 'Rest', 'action' => 'disparador', 'ext' => 'json'), array('version' => '[1-2]'));
Router::mapResources('Oxicode.Rest', array('prefix' => 'api'));
Router::resourceMap(array(array('action' => 'login', 'method' => 'POST', 'id' => false)));
Example #8
0
 * 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::mapResources('fxchng');
Router::parseExtensions('json');
Router::resourceMap(array(array('controller' => 'categories', 'action' => 'index', 'method' => 'POST'), array('controller' => 'categories', 'action' => 'sub_category_items', 'method' => 'POST', 'id' => true), array('controller' => 'categories', 'action' => 'product_detail', 'method' => 'POST', 'id' => true), array('controller' => 'categories', 'action' => 'get_brands', 'method' => 'POST', 'id' => true), array('controller' => 'categories', 'action' => 'get_roles', 'method' => 'POST', 'id' => false), array('controller' => 'categories', 'action' => 'common_friend', 'method' => 'POST', 'id' => false), array('controller' => 'categories', 'action' => 'mutual_friend', 'method' => 'POST', 'user_fb_id' => true, 'ad_fb_id' => true), array('action' => 'update', 'method' => 'POST', 'id' => true)));
Router::connect('/', array('controller' => 'home', 'action' => 'index', '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.
 */
require CAKE . 'Config' . DS . 'routes.php';