本文整理汇总了PHP中Router::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::connect方法的具体用法?PHP Router::connect怎么用?PHP Router::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* Conecta una nueva ruta interpretada al enrutador
*
*
* @param string $route
* @param array $defaults
* @param array $options
*/
function connect($route, $defaults = array(), $options = array())
{
$self = I18nRouter::getInstance();
$route = $self->interpretUrl($route);
//pr($route);
Router::connect($route, $defaults, $options);
}
示例2: startTest
public function startTest()
{
Configure::write('Cache.disable', false);
Router::reload();
Router::connect('/:controller/:action/*', array(), array('routeClass' => 'SluggableRoute', 'models' => array('RouteTest')));
$this->RouteTest = ClassRegistry::init('RouteTest');
}
示例3: version
/**
* Get or set version info (DB)
*
* @param string $extension
* @param string $newVersion
*/
public static function version($extension = 'core', $newVersion = null)
{
if (SlConfigure::read('Sl.installPending')) {
return SlConfigure::read('Sl.version');
}
if (!SlConfigure::read('Mirror.version')) {
App::import('Core', 'ConnectionManager');
$db = @ConnectionManager::getDataSource('default');
if (!$db->isConnected() || !in_array("{$db->config['prefix']}core_versions", $db->listSources())) {
if (strpos(Sl::url(false), '/install') === false) {
Router::connect(Sl::url(false), array('controller' => 'install'));
}
return;
}
App::import('Core', 'ClassRegistry');
ClassRegistry::init('Version')->refreshMirror();
}
if ($newVersion) {
$versionModel = ClassRegistry::init('Version');
$id = $versionModel->field('Version.id', array('Version.name' => $extension));
$versionModel->create();
return $versionModel->save(array('id' => $id, 'name' => $extension, 'version' => $newVersion));
}
return SlConfigure::read("Mirror.version.{$extension}");
}
示例4: testPasRedirect
/**
* testPasRedirect
*
* @return void
*/
public function testPasRedirect()
{
Router::connect('/:controller/:action/*');
$this->Controller->action = 'index';
$this->Pas->pasRedirect(array('action' => 'index'));
$expected = array('action' => 'index');
$this->assertEqual($expected, $this->Controller->redirectUrl);
// Test for redirect status and whether exit or not
$this->Pas->pasRedirect(array('action' => 'index'), 302, false);
$expected = array('action' => 'index');
$this->assertEqual($expected, $this->Controller->redirectUrl);
$this->assertEqual(302, $this->Controller->redirectStatus);
$this->assertEqual(false, $this->Controller->exit);
$this->Controller->request->params['named'] = array('page' => 1);
$this->Controller->request->query = array('foo' => 'bar');
$this->Pas->pasRedirect('/posts/index');
$expected = array('plugin' => false, 'controller' => 'posts', 'action' => 'index', 'page' => 1, '?' => array('foo' => 'bar'));
$this->assertEqual($expected, $this->Controller->redirectUrl);
$this->Pas->pasRedirect('/posts/index/page:2?foo=baz');
$expected = array('plugin' => false, 'controller' => 'posts', 'action' => 'index', 'page' => 2, '?' => array('foo' => 'baz'));
$this->assertEqual($expected, $this->Controller->redirectUrl);
// Test for named and query
$this->Pas->pasRedirect(array('action' => 'index'));
$expected = array('action' => 'index', 'page' => 1, '?' => array('foo' => 'bar'));
$this->assertEqual($expected, $this->Controller->redirectUrl);
// Test for overriding
$expected = array('action' => 'index', 'page' => 2, '?' => array('foo' => 'baz'));
$this->Pas->pasRedirect(array('action' => 'index', 'page' => 2, '?' => array('foo' => 'baz')));
$this->assertEqual($expected, $this->Controller->redirectUrl);
}
示例5: setUp
function setUp()
{
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->Controller =& ClassRegistry::init('Controller');
$this->Controller->Component =& ClassRegistry::init('Component');
$this->Controller->Toolbar =& ClassRegistry::init('TestToolBarComponent', 'Component');
}
示例6: setUp
/**
* set Up test case
*
* @return void
**/
function setUp()
{
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->Controller =& ClassRegistry::init('Controller');
$this->View =& new DebugView($this->Controller, false);
$this->_debug = Configure::read('debug');
}
示例7: connect
function connect($route, $default = array(), $params = array())
{
parent::connect($route, $default, $params);
if ($route == '/') {
$route = '';
}
parent::connect('/:locale', $default, array_merge(array('locale' => '[a-z]{3}'), $params));
}
示例8: setUp
/**
* set Up test case
*
* @return void
**/
public function setUp()
{
parent::setUp();
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->Controller = new Controller();
$this->View = new DebugView($this->Controller, false);
}
示例9: connect
/**
* This method tried to mimic the original `Router::connect` adding some
* extra params and handling the insertion of necessary options to it.
*
* @param string $name A unique name for this route.
* @param string $route A string describing the template of the route.
* @param array $defaults An array describing the default route parameters.
* These parameters will be used by default and can
* supply routing parameters that are not dynamic.
* @param array $options An array matching the named elements in the route
* to regular expressions which that element should
* match. Also contains additional parameters such as
* which routed parameters should be shifted into the
* passed arguments and supplying patterns for routing
* parameters.
* @return array Array of routes.
*/
public static function connect($name, $route, $defaults = array(), $options = array())
{
$extra = array('routeClass' => 'PowerRoute');
if (!empty($name)) {
$extra['routeName'] = $name;
}
return Router::connect($route, $defaults, array_merge($extra, $options));
}
示例10: registerRoutes
public function registerRoutes()
{
$routes = new RouteCollection();
foreach ($this->routerConfiguration as $routeName => $singleRoute) {
$routes->add($routeName, new Route($singleRoute['path'], $singleRoute['defaults']));
$singleRouteCakePath = preg_replace("/(\\{)(\\w+)(\\})/", ":\$2", $singleRoute['path']);
Router::connect($singleRouteCakePath, $singleRoute['defaults']);
}
$this->routes = $routes;
}
示例11: setUp
/**
* Setup
*
* @return void
*/
public function setUp()
{
Configure::write('App.linkMap', array('blogSlug' => array('preset' => array('controller' => 'blog_posts', 'action' => 'view'), 'alias' => 'BlogPost', 'fieldMap' => array('id' => '{alias}.id', 'slug' => '{alias}.slug', 'categorySlug' => 'Category.slug'), 'titleField' => 'BlogPost.title')));
$null = null;
$this->View = new View(null);
$this->View->Helpers->load('Html');
$this->Link = new LinkHelper($this->View);
Router::reload();
Router::connect('/article/:categorySlug/:slug-:id', array('controller' => 'blog_posts', 'action' => 'view'));
}
示例12: startTest
/**
* setUp
*
* @return void
**/
function startTest()
{
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->Asset =& new AssetHelper();
$this->Asset->Html =& new HtmlHelper();
$this->Controller =& ClassRegistry::init('Controller');
if (isset($this->_debug)) {
Configure::write('debug', $this->_debug);
}
}
示例13: setUp
/**
* setUp
*
* @return void
**/
function setUp()
{
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->Toolbar =& new ToolbarHelper(array('output' => 'DebugKit.FirePhpToolbar'));
$this->Toolbar->FirePhpToolbar =& new FirePhpToolbarHelper();
$this->Controller =& ClassRegistry::init('Controller');
if (isset($this->_debug)) {
Configure::write('debug', $this->_debug);
}
}
示例14: startTest
function startTest()
{
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->GpsForm =& new GpsFormHelper();
$this->GpsForm->MockBackend = new MockBackendHelper();
$this->Controller =& ClassRegistry::init('Controller');
if (isset($this->_debug)) {
Configure::write('debug', $this->_debug);
}
}
示例15: setUp
/**
* setUp
*
* @return void
**/
public function setUp()
{
parent::setUp();
Router::connect('/:controller/:action');
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::parse('/');
$this->Controller = new Controller($this->getMock('CakeRequest'), new CakeResponse());
$this->View = new View($this->Controller);
$this->Toolbar = new ToolbarHelper($this->View, array('output' => 'DebugKit.FirePhpToolbar'));
$this->Toolbar->FirePhpToolbar = new FirePhpToolbarHelper($this->View);
$this->firecake = FireCake::getInstance();
}