Skip to content

Commit bdaad9d

Browse files
committed
minor #12345 Update the code related to controllers in events (javiereguiluz)
This PR was squashed before being merged into the 3.4 branch (closes #12345). Discussion ---------- Update the code related to controllers in events Replaces #10194. Commits ------- c4c926b Update the code related to controllers in events
2 parents c6e3cba + c4c926b commit bdaad9d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

event_dispatcher/before_after_filters.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,13 @@ event subscribers, you can learn more about them at :doc:`/event_dispatcher`::
133133
{
134134
$controller = $event->getController();
135135

136-
/*
137-
* $controller passed can be either a class or a Closure.
138-
* This is not usual in Symfony but it may happen.
139-
* If it is a class, it comes in array format
140-
*/
141-
if (!is_array($controller)) {
142-
return;
136+
// when a controller class defines multiple action methods, the controller
137+
// is returned as [$controllerInstance, 'methodName']
138+
if (is_array($controller)) {
139+
$controller = $controller[0];
143140
}
144141

145-
if ($controller[0] instanceof TokenAuthenticatedController) {
142+
if ($controller instanceof TokenAuthenticatedController) {
146143
$token = $event->getRequest()->query->get('token');
147144
if (!in_array($token, $this->tokens)) {
148145
throw new AccessDeniedHttpException('This action needs a valid token!');

0 commit comments

Comments
 (0)