当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::connect方法代码示例

本文整理汇总了PHP中Cake\Routing\Router::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::connect方法的具体用法?PHP Router::connect怎么用?PHP Router::connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Routing\Router的用法示例。


在下文中一共展示了Router::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testResetLink

 /**
  * Tests
  *
  * @return void
  */
 public function testResetLink()
 {
     Router::connect('/:controller/:action/*');
     $result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
     $this->Html->request->here = '/admin/foobar/test';
     $this->Html->request->params['admin'] = true;
     $this->Html->request->params['prefix'] = 'admin';
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::prefix('admin', function ($routes) {
         $routes->connect('/:controller/:action/*');
     });
     $result = $this->Html->link('Foo', ['prefix' => 'admin', 'controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/admin/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
     $result = $this->Html->link('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/admin/foobar/test">Foo</a>';
     //debug($result);
     //$this->assertEquals($expected, $result);
     $result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
     $expected = '<a href="/foobar/test">Foo</a>';
     $this->assertEquals($expected, $result);
 }
开发者ID:olmprakash,项目名称:cakephp-tools,代码行数:30,代码来源:HtmlHelperTest.php

示例2: testQueryStringAndCustomTime

 /**
  * test setting parameters in beforeDispatch method
  *
  * @return void
  */
 public function testQueryStringAndCustomTime()
 {
     $folder = CACHE . 'views' . DS;
     $file = $folder . 'posts-home-coffee-life-sleep-sissies-coffee-life-sleep-sissies.html';
     $content = '<!--cachetime:' . (time() + WEEK) . ';ext:html-->Foo bar';
     file_put_contents($file, $content);
     Router::reload();
     Router::connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
     Router::connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
     Router::connect('/:controller/:action/*');
     $_GET = ['coffee' => 'life', 'sleep' => 'sissies'];
     $filter = new CacheFilter();
     $request = new Request('posts/home/?coffee=life&sleep=sissies');
     $response = new Response();
     $event = new Event(__CLASS__, $this, compact('request', 'response'));
     $filter->beforeDispatch($event);
     $result = $response->body();
     $expected = '<!--created:';
     $this->assertTextStartsWith($expected, $result);
     $expected = '-->Foo bar';
     $this->assertTextEndsWith($expected, $result);
     $result = $response->type();
     $expected = 'text/html';
     $this->assertEquals($expected, $result);
     $result = $response->header();
     $this->assertNotEmpty($result['Expires']);
     // + 1 week
     unlink($file);
 }
开发者ID:jxav,项目名称:cakephp-cache,代码行数:34,代码来源:CacheFilterTest.php

示例3: testBuildResetWithPlugin

 /**
  * @return void
  */
 public function testBuildResetWithPlugin()
 {
     Router::connect('/:controller/:action/*');
     $result = $this->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
     $expected = '/foobar/test';
     $this->assertSame($expected, $result);
     $this->Url->request->here = '/admin/foo/bar/baz/test';
     $this->Url->request->params['prefix'] = 'admin';
     $this->Url->request->params['plugin'] = 'Foo';
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::plugin('Foo', function ($routes) {
         $routes->fallbacks();
     });
     Router::prefix('admin', function ($routes) {
         $routes->plugin('Foo', function ($routes) {
             $routes->fallbacks();
         });
     });
     Plugin::routes();
     Router::pushRequest($this->Url->request);
     $result = $this->Url->build(['controller' => 'bar', 'action' => 'baz', 'x']);
     $expected = '/admin/foo/bar/baz/x';
     $this->assertSame($expected, $result);
     $result = $this->Url->buildReset(['controller' => 'bar', 'action' => 'baz', 'x']);
     $expected = '/bar/baz/x';
     $this->assertSame($expected, $result);
 }
开发者ID:dereuromark,项目名称:cakephp-tools,代码行数:31,代码来源:UrlHelperTest.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     $this->View = new View();
     $this->AbsoluteAdmin = new AbsoluteAdminHelper($this->View);
     Router::connect('/:controller', ['action' => 'index']);
     Router::connect('/:controller/:action/*');
 }
开发者ID:orgasmicnightmare,项目名称:cakephp-absolute-admin-theme,代码行数:8,代码来源:AbsoluteAdminHelperTest.php

示例5: setUp

 public function setUp()
 {
     parent::setUp();
     Router::connect('/ann-authorize-test/allowedAction', ['controller' => 'AnnAuthorizeTest', 'action' => 'allowedAction']);
     Router::connect('/ann-authorize-test/loggedInAction', ['controller' => 'AnnAuthorizeTest', 'action' => 'loggedInAction']);
     $this->annAuthorizeHelper = new AnnAuthorizeHelper(new View());
     $this->annAuthorizeHelper->request = new Request();
 }
开发者ID:michaelze,项目名称:cakephp-annauthorize,代码行数:8,代码来源:AnnAuthorizeHelperTest.php

示例6: setUp

 public function setUp()
 {
     parent::setUp();
     Router::connect('/test/test', ['controller' => 'Test', 'action' => 'test']);
     Router::connect('/test/test1', ['controller' => 'Test', 'action' => 'test1']);
     Router::connect('/test/test2', ['controller' => 'Test', 'action' => 'test2']);
     Router::connect('/test/test3', ['controller' => 'Test', 'action' => 'test3']);
     static::$entityActionHelper = new EntityActionHelper(new View());
 }
开发者ID:michaelze,项目名称:cakephp-entityactions,代码行数:9,代码来源:EntityActionHelperTest.php

示例7: setUp

 /**
  * Setup method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Router::connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);
     DispatcherFactory::clear();
     DispatcherFactory::add('Routing');
     DispatcherFactory::add('ControllerFactory');
 }
开发者ID:kfer10,项目名称:excel,代码行数:14,代码来源:IntegrationTestCaseTest.php

示例8: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Router::connect('/:controller/:action');
     $request = new Request();
     $request->addParams(array('controller' => 'pages', 'action' => 'display'));
     $this->View = new View($request);
     $this->Toolbar = new ToolbarHelper($this->View);
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:14,代码来源:ToolbarHelperTest.php

示例9: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->io = $this->getMock('Cake\\Console\\ConsoleIo', ['helper', 'out', 'err']);
     $this->table = $this->getMock('Cake\\Shell\\Helper\\TableHelper', [], [$this->io]);
     $this->io->expects($this->any())->method('helper')->with('table')->will($this->returnValue($this->table));
     $this->shell = new RoutesShell($this->io);
     Router::connect('/articles/:action/*', ['controller' => 'Articles']);
     Router::connect('/bake/:controller/:action', ['plugin' => 'Bake']);
     Router::connect('/tests/:action/*', ['controller' => 'Tests'], ['_name' => 'testName']);
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:16,代码来源:RoutesShellTest.php

示例10: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->View = new View();
     $this->View->Html = new BootstrapHtmlHelper($this->View);
     $this->Paginator = new BootstrapPaginatorHelper($this->View);
     $this->Paginator->request = new Request();
     $this->Paginator->request->addParams(['paging' => ['Article' => ['page' => 1, 'current' => 9, 'count' => 62, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 7, 'sort' => null, 'direction' => null, 'limit' => null]]]);
     Configure::write('Routing.prefixes', []);
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::connect('/:plugin/:controller/:action/*');
 }
开发者ID:alescx,项目名称:cakephp3-bootstrap-helpers,代码行数:18,代码来源:BootstrapPaginatorHelperTest.php

示例11: setUp

 /**
  * [setUp description]
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->resetReflectionCache();
     $this->_eventManager = EventManager::instance();
     $existing = Configure::read('App.paths.templates');
     $existing[] = Plugin::path('Crud') . 'tests/App/Template/';
     Configure::write('App.paths.templates', $existing);
     Configure::write('App.namespace', 'Crud\\Test\\App');
     Router::extensions('json');
     Router::connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);
     Router::connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);
     $this->useHttpServer(false);
 }
开发者ID:friendsofcake,项目名称:crud,代码行数:19,代码来源:IntegrationTestCase.php

示例12: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('Config.language', 'eng');
     $this->View = new View();
     $this->Paginator = new PaginatorHelper($this->View);
     $this->Paginator->Js = $this->getMock('Cake\\View\\Helper\\PaginatorHelper', [], [$this->View]);
     $this->Paginator->request = new Request();
     $this->Paginator->request->addParams(['paging' => ['Article' => ['page' => 1, 'current' => 9, 'count' => 62, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 7, 'sort' => null, 'direction' => null, 'limit' => null]]]);
     Configure::write('Routing.prefixes', []);
     Router::reload();
     Router::connect('/:controller/:action/*');
     Router::connect('/:plugin/:controller/:action/*');
     $this->locale = I18n::locale();
 }
开发者ID:olafthelofty,项目名称:carenta,代码行数:20,代码来源:PaginatorHelperTest.php

示例13: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->backupUsersConfig = Configure::read('Users');
     Router::reload();
     Plugin::routes('CakeDC/Users');
     Router::connect('/route/*', ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'requestResetPassword']);
     Security::salt('YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
     Configure::write('App.namespace', 'Users');
     $this->request = $this->getMock('Cake\\Network\\Request', ['is', 'method']);
     $this->request->expects($this->any())->method('is')->will($this->returnValue(true));
     $this->response = $this->getMock('Cake\\Network\\Response', ['stop']);
     $this->Controller = new Controller($this->request, $this->response);
     $this->Registry = $this->Controller->components();
     $this->Controller->UsersAuth = new UsersAuthComponent($this->Registry);
 }
开发者ID:GF-TIC,项目名称:users,代码行数:21,代码来源:UsersAuthComponentTest.php

示例14: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
     Configure::write('App.namespace', 'TestApp');
     $request = new Request();
     $response = $this->getMock('Cake\\Network\\Response', array('stop'));
     $this->Controller = new AuthTestController($request, $response);
     $this->Controller->constructClasses();
     $this->Auth = new TestAuthComponent($this->Controller->components());
     $this->Auth->request = $request;
     $this->Auth->response = $response;
     AuthComponent::$sessionKey = 'Auth.User';
     $this->initialized = true;
     Router::reload();
     Router::connect('/:controller/:action/*');
     $Users = TableRegistry::get('AuthUsers');
     $Users->updateAll(['password' => Security::hash('cake', 'blowfish', false)], []);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:24,代码来源:AuthComponentTest.php

示例15: setUp

 public function setUp()
 {
     parent::setUp();
     Configure::write('Config.language', 'eng');
     Configure::write('App.base', '');
     Configure::write('App.namespace', 'BootstrapUI\\Test\\TestCase\\View\\Helper');
     Configure::delete('Asset');
     $this->View = new View();
     $this->Form = new FormHelper($this->View);
     $request = new Request('articles/add');
     $request->here = '/articles/add';
     $request['controller'] = 'articles';
     $request['action'] = 'add';
     $request->webroot = '';
     $request->base = '';
     $this->Form->Url->request = $this->Form->request = $request;
     $this->article = ['schema' => ['id' => ['type' => 'integer'], 'author_id' => ['type' => 'integer', 'null' => true], 'title' => ['type' => 'string', 'null' => true], 'body' => 'text', 'published' => ['type' => 'boolean', 'length' => 1, 'default' => 0], '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]]], 'required' => ['author_id' => true, 'title' => true]];
     Security::salt('foo!');
     Router::connect('/:controller', ['action' => 'index']);
     Router::connect('/:controller/:action/*');
 }
开发者ID:2km,项目名称:bootstrap-ui,代码行数:21,代码来源:FormHelperTest.php


注:本文中的Cake\Routing\Router::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。