本文整理汇总了PHP中Router::connectNamed方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::connectNamed方法的具体用法?PHP Router::connectNamed怎么用?PHP Router::connectNamed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::connectNamed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* undocumented function
*
* @return void
*/
function index()
{
$this->set('disableNav', true);
Router::connectNamed(array('type', 'page'));
if (empty($this->passedArgs['type'])) {
$this->passedArgs['type'] = 'public';
$projects = $this->Project->User->groups($this->Auth->user('id'));
if (!empty($projects)) {
$this->Session->write('Auth.User.ProjectPermission', $projects);
$this->passedArgs['type'] = null;
$this->paginate['conditions'] = array('Project.id' => array_keys($projects));
$this->paginate['order'] = 'Project.private DESC, Project.url ASC';
}
}
if (!empty($this->passedArgs['type'])) {
$this->paginate['conditions'] = array('Project.private' => 0, 'Project.active' => 1, 'Project.approved' => 1);
if ($this->passedArgs['type'] == 'forks') {
$this->paginate['conditions']['Project.fork !='] = null;
$this->paginate['order'] = 'Project.url ASC';
} else {
if ($this->passedArgs['type'] == 'public') {
$this->paginate['conditions']['Project.fork ='] = null;
$this->paginate['order'] = 'Project.url ASC';
}
}
}
if (User::get('id') == 1) {
unset($this->paginate['conditions']);
$this->paginate['order'] = 'Project.private ASC, Project.url ASC';
}
$this->Project->recursive = 0;
$projects = $this->paginate();
$this->set('projects', $projects);
$this->set('rssFeed', array('controller' => 'projects'));
}
示例2: initialize
/**
* undocumented function
*
* @param string $controller
* @param string $options
* @return void
*/
function initialize($controller, $options)
{
$this->params = $_GET;
unset($this->params['url']);
if (!empty($options['keys'])) {
$this->keys($options['keys']);
}
if (!empty($options['connect'])) {
Router::connectNamed($options['connect']);
} else {
Router::connectNamed($this->keys);
}
if (!empty($options['count'])) {
$this->enabled = count($this->params) >= $options['count'] ? true : false;
} else {
$this->enabled = count($this->params) >= count($this->keys) ? true : false;
}
if (!empty($options['actions'])) {
$this->allowedActions = $options['actions'];
}
if (!$this->enabled) {
foreach ($this->keys as $key) {
if (isset($controller->params['named'][$key])) {
if (strpos($controller->params['named'][$key], ',') !== false) {
$controller->data[$controller->modelClass][$key] = explode(',', $controller->params['named'][$key]);
} else {
$controller->data[$controller->modelClass][$key] = $controller->params['named'][$key];
}
}
}
}
}
示例3: index
/**
* undocumented function
*
* @return void
*/
function index()
{
Router::connectNamed(array('type', 'page'));
if (empty($this->paginate['conditions'])) {
$this->paginate['conditions'] = array('Timeline.project_id' => $this->Project->id);
}
if (!empty($this->passedArgs['type'])) {
$this->paginate['conditions']['Timeline.model'] = Inflector::classify($this->passedArgs['type']);
} else {
if ($this->action !== 'forks') {
$this->passedArgs['type'] = null;
}
}
$this->Timeline->recursive = 0;
$this->set('timeline', $this->paginate());
$this->set('rssFeed', array('controller' => 'timeline'));
}
示例4: index
/**
* undocumented function
*
* @return void
*/
function index()
{
Router::connectNamed(array('page', 'type'));
$this->set('rssFeed', array('controller' => 'dashboard', 'action' => 'feed'));
extract($this->Project->User->projects($this->Auth->user('id')));
if (empty($ids)) {
return;
}
$this->paginate['conditions']['Timeline.project_id'] = $ids;
if (!empty($this->passedArgs['type'])) {
$this->paginate['conditions']['Timeline.model'] = Inflector::classify($this->passedArgs['type']);
} else {
if ($this->action !== 'forks') {
$this->passedArgs['type'] = null;
}
}
$this->set('timeline', $this->paginate('Timeline'));
}
示例5: index
function index($id = null)
{
if (!isset($this->params['type'])) {
$this->cakeError('error404');
}
$extraArgsForPaging['type'] = $this->paginate[0] = $this->params['type'];
if (isset($id)) {
$this->paginate['conditions']['id'] = $id;
}
foreach ($this->passedArgs as $arg => $value) {
if (in_array($arg, $this->conditionsByType[$this->params['type']])) {
$this->paginate['conditions'][$arg] = $value;
}
}
if (!empty($this->paginate['conditions'])) {
Router::connectNamed(array_keys($this->paginate['conditions']), array('default' => true));
}
$users = $this->paginate();
$this->set(compact('users', 'extraArgsForPaging'));
}
示例6:
* @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('/', ['controller' => 'pages', 'action' => 'display', 'home']);
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
Router::connectNamed(false);
Router::connect('/pages/api', ['controller' => 'api']);
Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']);
Router::connect('/spectra', ['controller' => 'reports', 'action' => 'index']);
Router::connect('/compounds', ['controller' => 'substances', 'action' => 'index']);
Router::connect('/compounds/:action/*', ['controller' => 'substances']);
Router::connect('/splashes', ['controller' => 'reports', 'action' => 'splashes']);
Router::connect('/spectra/:action/*', ['controller' => 'reports']);
/**
* 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.
示例7: array
*/
Router::parseExtensions('json', 'csv', 'print');
/**
* Bring in custom routing libraries
*/
App::import('Lib', array('Slugger.routes/SluggableRoute'));
/**
* Static routes
*/
Router::connect('/', array('controller' => 'profiles', 'action' => 'view'));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/pages/phrase/*', array('controller' => 'pages', 'action' => 'phrase'));
Router::connect('/pages/message/*', array('controller' => 'pages', 'action' => 'message'));
/**
* Custom routes
*/
Router::connectNamed(array('User', 'Ministry', 'Involvement', 'Campus', 'model'), array('defaults' => true));
Router::connect('/involvements/:action/*', array('controller' => 'involvements'), array('routeClass' => 'SluggableRoute', 'models' => array('Involvement'), 'prependPk' => true));
Router::connect('/ministries/:action/*', array('controller' => 'ministries'), array('routeClass' => 'SluggableRoute', 'models' => array('Ministry'), 'prependPk' => true));
Router::connect('/campuses/:action/*', array('controller' => 'campuses'), array('routeClass' => 'SluggableRoute', 'models' => array('Campus'), 'prependPk' => true));
Router::connect('/:controller/:action/*', array(), array('routeClass' => 'SluggableRoute', 'models' => array('User'), 'controller' => 'users|profiles', 'prependPk' => true));
/*
* Asset Compress
*/
Router::connect('/css_cache/*', array('plugin' => 'asset_compress', 'controller' => 'css_files', 'action' => 'get'));
Router::connect('/js_cache/*', array('plugin' => 'asset_compress', 'controller' => 'js_files', 'action' => 'get'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
示例8: array
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP(tm) v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/*次の設定はdocomo携帯でのセッション管理のための設定*/
Router::connectNamed(array(), array('argSeparator' => '~'));
/**
* 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' => 'users', 'action' => 'index'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/cake/users/', array('controller' => 'users', 'action' => 'index'));
Router::connect('/cake/twitters/', array('controller' => 'twitters', 'action' => 'index'));
示例9: testParseNamedKeyUrlDecode
/**
* Ensure that keys at named parameters are urldecoded
*
* @return void
*/
public function testParseNamedKeyUrlDecode()
{
Router::connectNamed(true);
$route = new CakeRoute('/:controller/:action/*', array('plugin' => null));
// checking /post/index/user[0]:a/user[1]:b
$result = $route->parse('/posts/index/user%5B0%5D:a/user%5B1%5D:b');
$this->assertArrayHasKey('user', $result['named']);
$this->assertEquals(array('a', 'b'), $result['named']['user']);
// checking /post/index/user[]:a/user[]:b
$result = $route->parse('/posts/index/user%5B%5D:a/user%5B%5D:b');
$this->assertArrayHasKey('user', $result['named']);
$this->assertEquals(array('a', 'b'), $result['named']['user']);
}
示例10: testNamedArgsUrlParsing
/**
* testNamedArgsUrlParsing method
*
* @access public
* @return void
*/
function testNamedArgsUrlParsing()
{
$Router =& Router::getInstance();
Router::reload();
$result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value');
$expected = array('pass' => array(), 'named' => array('param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
$this->assertEqual($result, $expected);
Router::reload();
$result = Router::connectNamed(false);
$this->assertEqual(array_keys($result['rules']), array());
$this->assertFalse($result['greedy']);
$result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value');
$expected = array('pass' => array('param1:value1:1', 'param2:value2:3', 'param:value'), 'named' => array(), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
$this->assertEqual($result, $expected);
Router::reload();
$result = Router::connectNamed(true);
$this->assertEqual(array_keys($result['rules']), $Router->named['default']);
$this->assertTrue($result['greedy']);
Router::reload();
Router::connectNamed(array('param1' => 'not-matching'));
$result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value');
$expected = array('pass' => array('param1:value1:1'), 'named' => array('param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
$this->assertEqual($result, $expected);
Router::reload();
Router::connect('/foo/:action/*', array('controller' => 'bar'), array('named' => array('param1' => array('action' => 'index')), 'greedy' => true));
$result = Router::parse('/foo/index/param1:value1:1/param2:value2:3/param:value');
$expected = array('pass' => array(), 'named' => array('param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'), 'controller' => 'bar', 'action' => 'index', 'plugin' => null);
$this->assertEqual($result, $expected);
$result = Router::parse('/foo/view/param1:value1:1/param2:value2:3/param:value');
$expected = array('pass' => array('param1:value1:1'), 'named' => array('param2' => 'value2:3', 'param' => 'value'), 'controller' => 'bar', 'action' => 'view', 'plugin' => null);
$this->assertEqual($result, $expected);
Router::reload();
Router::connectNamed(array('param1' => '[\\d]', 'param2' => '[a-z]', 'param3' => '[\\d]'));
$result = Router::parse('/controller/action/param1:1/param2:2/param3:3');
$expected = array('pass' => array('param2:2'), 'named' => array('param1' => '1', 'param3' => '3'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
$this->assertEqual($result, $expected);
Router::reload();
Router::connectNamed(array('param1' => '[\\d]', 'param2' => true, 'param3' => '[\\d]'));
$result = Router::parse('/controller/action/param1:1/param2:2/param3:3');
$expected = array('pass' => array(), 'named' => array('param1' => '1', 'param2' => '2', 'param3' => '3'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
$this->assertEqual($result, $expected);
Router::reload();
Router::connectNamed(array('param1' => 'value[\\d]+:[\\d]+'), array('greedy' => false));
$result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param3:value');
$expected = array('pass' => array('param2:value2:3', 'param3:value'), 'named' => array('param1' => 'value1:1'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null);
$this->assertEqual($result, $expected);
Router::reload();
Router::connect('/foo/*', array('controller' => 'bar', 'action' => 'fubar'), array('named' => array('param1' => 'value[\\d]:[\\d]')));
Router::connectNamed(array(), array('greedy' => false));
$result = Router::parse('/foo/param1:value1:1/param2:value2:3/param3:value');
$expected = array('pass' => array('param2:value2:3', 'param3:value'), 'named' => array('param1' => 'value1:1'), 'controller' => 'bar', 'action' => 'fubar', 'plugin' => null);
$this->assertEqual($result, $expected);
}
示例11: foreach
App::uses('PluginShortRoute', 'Routing/Route');
foreach ($plugins as $key => $value) {
$plugins[$key] = Inflector::underscore($value);
}
$pluginPattern = implode('|', $plugins);
$match = array('plugin' => $pluginPattern, 'defaultRoute' => true);
$shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern, 'defaultRoute' => true);
foreach ($prefixes as $prefix) {
$params = array('prefix' => $prefix, $prefix => true);
$indexParams = $params + array('action' => 'index');
Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams);
Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match);
Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match);
}
Router::connect('/:plugin', array('action' => 'index'), $shortParams);
Router::connect('/:plugin/:controller', array('action' => 'index'), $match);
Router::connect('/:plugin/:controller/:action/*', array(), $match);
}
foreach ($prefixes as $prefix) {
$params = array('prefix' => $prefix, $prefix => true);
$indexParams = $params + array('action' => 'index');
Router::connect("/{$prefix}/:controller", $indexParams, array('defaultRoute' => true));
Router::connect("/{$prefix}/:controller/:action/*", $params, array('defaultRoute' => true));
}
Router::connect('/:controller', array('action' => 'index'), array('defaultRoute' => true));
Router::connect('/:controller/:action/*', array(), array('defaultRoute' => true));
$namedConfig = Router::namedConfig();
if ($namedConfig['rules'] === false) {
Router::connectNamed(true);
}
unset($namedConfig, $params, $indexParams, $prefix, $prefixes, $shortParams, $match, $pluginPattern, $plugins, $key, $value);
示例12: array
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.app.config
* @since CakePHP(tm) v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
include_once ROOT . '/app/plugins/spark_plug/config/routes.php';
Router::connect('/', array('plugin' => 'spark_plug', 'controller' => 'users', 'action' => 'register'));
Router::connect('/admin', array('controller' => 'homepage', 'action' => 'index', "admin" => true));
Router::connect('/admin/login', array('controller' => 'users', 'action' => 'login', "admin" => true));
Router::connect('/downloads/*', array('controller' => 'downloads', 'action' => 'file'));
Router::connect('/websites/:action/*', array('controller' => 'websites'));
Router::connect('/company_files/:action/*', array('controller' => 'company_files'));
Router::connect('/customers/:action/*', array('controller' => 'customers'));
Router::connect('/products/:action/*', array('controller' => 'products'));
Router::connect('/payments/:action/*', array('controller' => 'payments'));
Router::connectNamed(array('page'));
Router::connect('/:slug/*', array('controller' => 'websites', 'action' => 'view'), array('pass' => array('slug')));
示例13: array
*/
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
//Main site routes: dashboard, profile, culture, search
Router::connect('/dashboard', array('controller' => 'users', 'action' => 'dashboard'));
Router::connect('/profile', array('controller' => 'users', 'action' => 'profile'));
Router::connect('/culture', array('controller' => 'users', 'action' => 'culture'));
Router::connect('/search', array('controller' => 'users', 'action' => 'search'));
Router::connect('/privacy', array('controller' => 'users', 'action' => 'privacy'));
Router::connect('/settings', array('controller' => 'users', 'action' => 'settings'));
Router::connect('/register', array('controller' => 'users', 'action' => 'register'));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
Router::connect('/for/*', array('controller' => 'positions', 'action' => 'view'));
//change the url for users to "with" so fitin.today/with/<userhash> and the userhash can be personalized for a price
Router::connectNamed(array('url'));
Router::connect('/with/:url', array('controller' => 'employers', 'action' => 'view'), array('pass' => array("url")));
Router::connect('/hire/:url', array('controller' => 'applicants', 'action' => 'view'), array('pass' => array("url")));
Router::connect('/at/:url', array('controller' => 'companies', 'action' => 'view'), array('pass' => array("url")));
Router::connect('/under/:url', array('controller' => 'employers', 'action' => 'under'), array('pass' => array("url")));
Router::connect('/confirm', array('controller' => 'users', 'action' => 'confirm'));
Router::connect('/confirm/:url', array('controller' => 'requests', 'action' => 'confirm'), array('pass' => array("url")));
Router::connect('/passwordReset', array('controller' => 'users', 'action' => 'passwordReset'));
Router::connect('/passwordReset/:url', array('controller' => 'requests', 'action' => 'passwordReset'), array('pass' => array("url")));
//referral url
Router::connect('/join/:url', array('controller' => 'users', 'action' => 'join', array('url')));
Router::connect('/admin/users', array('controller' => 'users', 'action' => 'index'));
Router::connect('/admin/culture', array('controller' => 'cultureQuestions', 'action' => 'index'));
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
示例14: array
Router::connect('/bostad/*', array('controller' => 'object_items', 'action' => 'bostad'));
Router::connectNamed(array('print'));
/* Router::connect('/objekt/*', array('controller' => 'object_items', 'action' => 'view')); */
Router::connect('/bilder/*', array('controller' => 'object_items', 'action' => 'images'));
/* Router::connect('/o/*', array('controller' => 'object_items', 'action' => 'view', 'short' => true)); */
Router::connect('/hemnet/*', array('controller' => 'object_items', 'action' => 'view', 'layout' => 'hemnet'));
Router::connectNamed(array('types', 'areas', 'rooms', 'size', 'price', 'page', 'sort', 'direction', 'map'));
Router::connect('/sok/*', array('controller' => 'object_items', 'action' => 'search'));
// Pages
Router::connect('/kopa', array('controller' => 'pages', 'action' => 'kopa'));
Router::connect('/salja', array('controller' => 'pages', 'action' => 'salja'));
Router::connect('/omraden', array('controller' => 'pages', 'action' => 'omraden'));
Router::connect('/videos', array('controller' => 'pages', 'action' => 'videos'));
Router::connectNamed(array('page'));
Router::connect('/omrade/:name/*', array('controller' => 'pages', 'action' => 'omrade'), array('pass' => array('name')));
Router::connectNamed(array('types', 'areas', 'rooms', 'size', 'price', 'page', 'sort', 'direction', 'map'));
Router::connect('/medarbetare/objekt/*', array('controller' => 'pages', 'action' => 'medarbetare_objekt'));
Router::connect('/medarbetare/*', array('controller' => 'pages', 'action' => 'medarbetare'));
Router::connect('/tjanster', array('controller' => 'pages', 'action' => 'tjanster'));
Router::connect('/om', array('controller' => 'pages', 'action' => 'om'));
Router::connect('/partners/:category', array('controller' => 'pages', 'action' => 'partners'));
Router::connect('/partners', array('controller' => 'pages', 'action' => 'partners'));
Router::connect('/portfolio', array('controller' => 'pages', 'action' => 'portfolio'));
Router::connect('/portfolio/:category', array('controller' => 'pages', 'action' => 'portfolio'));
Router::connect('/aktiviteter', array('controller' => 'pages', 'action' => 'aktiviteter'));
Router::connect('/referenser', array('controller' => 'pages', 'action' => 'referenser'));
Router::connect('/jobba_hos_m2', array('controller' => 'pages', 'action' => 'jobba_hos_m2'));
Router::connect('/kontakta', array('controller' => 'pages', 'action' => 'kontakta'));
Router::connect('/video/*', array('controller' => 'videos', 'action' => 'video'));
Router::connect('/film/medarbetare/*', array('controller' => 'videos', 'action' => 'broker_video'));
Router::connect('/fastpris', array('controller' => 'pages', 'action' => 'fastpris'));
示例15: admin_index
/**
* undocumented function
*
* @return void
*/
function admin_index()
{
Router::connectNamed(array('page', 'type'));
$projects = $this->Project->forks();
array_unshift($projects, $this->Project->id);
$this->paginate['conditions']['Timeline.project_id'] = $projects;
if (!empty($this->passedArgs['type'])) {
$this->paginate['conditions']['Timeline.model'] = Inflector::classify($this->passedArgs['type']);
} else {
if ($this->action !== 'forks') {
$this->passedArgs['type'] = null;
}
}
$this->set('timeline', $this->paginate('Timeline'));
}