mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding option to remove application base path to Router::url()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6444 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e1e9a6fe28
commit
ab1a245086
2 changed files with 25 additions and 1 deletions
|
@ -670,10 +670,14 @@ class Router extends Object {
|
|||
$path = end($_this->__paths);
|
||||
}
|
||||
}
|
||||
$base = $path['base']; // dont need this anymore $_this->stripPlugin($path['base'], $params['plugin']);
|
||||
$base = $path['base'];
|
||||
$extension = $output = $mapped = $q = $frag = null;
|
||||
|
||||
if (is_array($url) && !empty($url)) {
|
||||
if (array_key_exists('base', $url) && $url['base'] === false) {
|
||||
$base = null;
|
||||
unset($url['base']);
|
||||
}
|
||||
if (isset($url['full_base']) && $url['full_base'] == true) {
|
||||
$full = true;
|
||||
unset($url['full_base']);
|
||||
|
|
|
@ -864,6 +864,26 @@ class RouterTest extends UnitTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testRemoveBase() {
|
||||
$this->router->reload();
|
||||
$this->router->setRequestInfo(array(
|
||||
array('controller' => 'controller', 'action' => 'index', 'form' => array(), 'url' => array(), 'bare' => 0, 'webservices' => null, 'plugin' => null),
|
||||
array('base' => '/base', 'here' => '/', 'webroot' => '/base/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array(), 'webservices' => null)
|
||||
));
|
||||
|
||||
$result = $this->router->url(array('controller' => 'my_controller', 'action' => 'my_action'));
|
||||
$expected = '/base/my_controller/my_action/';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->router->url(array('controller' => 'my_controller', 'action' => 'my_action', 'base' => false));
|
||||
$expected = '/my_controller/my_action/';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->router->url(array('controller' => 'my_controller', 'action' => 'my_action', 'base' => true));
|
||||
$expected = '/base/my_controller/my_action/base:1';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testParamsUrlParsing() {
|
||||
$this->router->reload();
|
||||
$this->router->connect('/', array('controller' => 'posts', 'action' => 'index'));
|
||||
|
|
Loading…
Add table
Reference in a new issue