Skip to content

Commit 086d7c6

Browse files
committed
Fix dispatch when parameters + dispatch can now return action return
1 parent 60802c9 commit 086d7c6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Framework.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ final class Framework
1414
/**
1515
* Dispatch the request
1616
* @throws \Exception
17+
* @return mixed
1718
*/
1819
public function dispatch()
1920
{
20-
$parts = explode('/', preg_replace('~^' . Basepath::get() . '~', '', $_SERVER['REQUEST_URI']));
21+
$requestUri = $_SERVER['REQUEST_URI'];
22+
$appendUri = strpos($requestUri, '?');
23+
$query = substr($requestUri, 0, $appendUri === false ? strlen($requestUri) : $appendUri);
24+
$parts = explode('/', preg_replace('~^' . Basepath::get() . '~', '', $query));
2125
$action = count($parts) >= 2 ? array_pop($parts) : 'index';
2226
if (!$action) {
2327
$action = 'index';
@@ -32,7 +36,7 @@ public function dispatch()
3236
if (!is_callable(array($controller, $action))) {
3337
throw new \Exception('action ' . $action . ' not found in controller ' . $controllerName);
3438
}
35-
$controller->$action();
39+
return $controller->$action();
3640
}
3741

3842
/**

0 commit comments

Comments
 (0)