Skip to content

Commit

Permalink
bug #2928 Fix: Check for the existence of a called action method (dev…
Browse files Browse the repository at this point in the history
…-sl)

This PR was merged into the 1.x branch.

Discussion
----------

Fix: Check for the existence of a called action method

500 error on call undefined method, when set undefined action ('del' for example).
I added checking for method exists.

Commits
-------

a2f1dd2 Fix: Check for the existence of a called action method
  • Loading branch information
javiereguiluz committed Sep 12, 2019
2 parents cd79350 + a2f1dd2 commit 740fef9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ protected function renderForbiddenActionError($action)
* @param array $arguments The arguments passed to the executed method
*
* @return mixed
*
* @throws \Exception
*/
protected function executeDynamicMethod($methodNamePattern, array $arguments = array())
{
Expand All @@ -794,6 +796,10 @@ protected function executeDynamicMethod($methodNamePattern, array $arguments = a
@trigger_error(sprintf('The %s method is deprecated since EasyAdmin 1.x and will be removed in 2.0. Use %s() instead', $methodName, $newMethodName), E_USER_DEPRECATED);
}

if (!method_exists($this, $methodName)) {
throw new \BadMethodCallException(sprintf('The %s method not exists in %s class', $methodName, get_class($this)));
}

return call_user_func_array(array($this, $methodName), $arguments);
}

Expand Down

0 comments on commit 740fef9

Please sign in to comment.