Project

General

Profile

Feature #104393

Updated by David Bruchmann about 13 hours ago

The `AfterRequestDispatchedEvent` is triggered after the content is completely rendered, even including the view. 
 If an action of another controller shall be rendered this adds up to the needed time and performance. 

 Therefore I propose another event, after the controller is resolved: 

 <pre> 
             $controller = $this->resolveController($request); 
             $this->eventDispatcher->dispatch(new AfterControllerResolvedEvent($controller, $request)); 
             $response = $controller->processRequest($request); 
 </pre> 

 As the code `$controller->processRequest($request)` triggers determination of the action too, the new Event wouldn't cover cases where just another action of the same controller should be dispatched individually, though. 
 To achieve this the code inside `ActionController::processRequest` had to be changed, so that determining the action would be separated from processing. This would be a deeper change though, but probably better and more reasonable than the proposed event. 
 When these two steps are separated it would be possible to include an event where controller and action are known already. Just forwarding wouldn't be included as that's done from inside the actions. 

 <pre> 
             $controller = $this->resolveController($request); 
             $action = $this->resolveControllerAction($request); 
             $this->eventDispatcher->dispatch(new AfterControllerActionResolvedEvent($controller, $request)); 
             $response = $controller->processRequest($request); 
 </pre>

Back