本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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/*');
}
示例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();
}
示例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());
}
示例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');
}
示例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);
}
示例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']);
}
示例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/*');
}
示例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);
}
示例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();
}
示例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);
}
示例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)], []);
}
示例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/*');
}