Skip to content

Commit

Permalink
allow actions without Action suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoulgrave committed Nov 9, 2017
1 parent 0f6a5e3 commit 86e0ba6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Bear/App.php
Expand Up @@ -134,9 +134,11 @@ protected function resolveRequest(): Response
$this->eventDispatcher->dispatch(ControllerResolutionEvent::EVENT_NAME, new ControllerResolutionEvent($this->request, $controllerInstance));

$action = $routingResolution->getAction();
$actionMethod = sprintf('%sAction', $action);

/** @var Response $response */
if (method_exists($controllerInstance, $actionMethod)) {
if (method_exists($controllerInstance, $action)) {
$response = $controllerInstance->{$action}($this->request);
} elseif (method_exists($controllerInstance, $actionMethod = sprintf('%sAction', $action))) {
$response = $controllerInstance->{$actionMethod}($this->request);
} else {
$response = new Response('Method not found', Response::HTTP_NOT_FOUND);
Expand Down

0 comments on commit 86e0ba6

Please sign in to comment.