Skip to content

Commit

Permalink
Fix dispatch when parameters + dispatch can now return action return
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed Nov 1, 2016
1 parent 60802c9 commit 086d7c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ final class Framework
/**
* Dispatch the request
* @throws \Exception
* @return mixed
*/
public function dispatch()
{
$parts = explode('/', preg_replace('~^' . Basepath::get() . '~', '', $_SERVER['REQUEST_URI']));
$requestUri = $_SERVER['REQUEST_URI'];
$appendUri = strpos($requestUri, '?');
$query = substr($requestUri, 0, $appendUri === false ? strlen($requestUri) : $appendUri);
$parts = explode('/', preg_replace('~^' . Basepath::get() . '~', '', $query));
$action = count($parts) >= 2 ? array_pop($parts) : 'index';
if (!$action) {
$action = 'index';
Expand All @@ -32,7 +36,7 @@ public function dispatch()
if (!is_callable(array($controller, $action))) {
throw new \Exception('action ' . $action . ' not found in controller ' . $controllerName);
}
$controller->$action();
return $controller->$action();
}

/**
Expand Down

0 comments on commit 086d7c6

Please sign in to comment.