Allow routing to nothing without looking up from the Request object

This commit is contained in:
Sam Georges 2014-07-14 19:06:23 +10:00
parent a2fba71c7f
commit 63b98f56c5
2 changed files with 10 additions and 5 deletions

View File

@ -61,7 +61,7 @@ class BackendController extends ControllerBase
if ($controllerObj = $this->findController($controllerClass, $action, Config::get('cms.pluginsDir', '/plugins')))
return $controllerObj->run($action, $controllerParams);
}
/*
* Fall back on Cms controller
*/

View File

@ -106,9 +106,9 @@ class Controller extends BaseController
* If the parameter is omitted, the current URL used.
* @return string Returns the processed page content.
*/
public function run($url = null)
public function run($url = '/')
{
if (!$url)
if ($url === null)
$url = Request::path();
if (!strlen($url))
@ -690,8 +690,13 @@ class Controller extends BaseController
if ($routePersistence)
$parameters = array_merge($this->router->getParameters(), $parameters);
$url = $this->router->findByFile($name, $parameters);
return ($url) ? URL::to($url) : null;
if (!$url = $this->router->findByFile($name, $parameters))
return null;
if (substr($url, 0, 1) == '/')
$url = substr($url, 1);
return URL::action('Cms\Classes\Controller@run', ['slug' => $url]);
}
/**