Skip to content

Commit

Permalink
Remove a param.
Browse files Browse the repository at this point in the history
Merge the hostOptions onto params. This
saves a parameter and makes the interface simpler.
  • Loading branch information
markstory committed Jul 4, 2012
1 parent 9f1bc1e commit 4ed0f54
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/Cake/Routing/Route/Route.php
Expand Up @@ -439,7 +439,8 @@ public function match($url, $context = array()) {
}
}
}
return $this->_writeUrl($url, $pass, $hostOptions, $query);
$url += $hostOptions;
return $this->_writeUrl($url, $pass, $query);
}

/**
Expand All @@ -450,7 +451,7 @@ public function match($url, $context = array()) {
* @param array $pass The additional passed arguments.
* @return string Composed route string.
*/
protected function _writeUrl($params, $pass = array(), $hostOptions = array(), $query = array()) {
protected function _writeUrl($params, $pass = array(), $query = array()) {
if (isset($params['prefix'], $params['action'])) {
$params['action'] = str_replace($params['prefix'] . '_', '', $params['action']);
unset($params['prefix']);
Expand All @@ -477,23 +478,27 @@ protected function _writeUrl($params, $pass = array(), $hostOptions = array(), $
}

// add base url if applicable.
if (isset($hostOptions['_base'])) {
$out = $hostOptions['_base'] . $out;
unset($hostOptions['_base']);
if (isset($params['_base'])) {
$out = $params['_base'] . $out;
unset($params['_base']);
}

$out = str_replace('//', '/', $out);

if (!empty($hostOptions)) {
$host = $hostOptions['_host'];
if (
isset($params['_scheme']) ||
isset($params['_host']) ||
isset($params['_port'])
) {
$host = $params['_host'];

// append the port if it exists.
if (isset($hostOptions['_port'])) {
$host .= ':' . $hostOptions['_port'];
if (isset($params['_port'])) {
$host .= ':' . $params['_port'];
}
$out = sprintf(
'%s://%s%s',
$hostOptions['_scheme'],
$params['_scheme'],
$host,
$out
);
Expand Down

0 comments on commit 4ed0f54

Please sign in to comment.