ZF2-171: Application finish event

Description

The application class no longer fires a finish event if a response object is returned from a controller action.

I suggest the following patch:


     // Trigger dispatch event 
     $result = $events->trigger('dispatch', $event, $shortCircuit); 

     // Complete response 
     $response = $result->last(); 
     if ($response instanceof Response) { 
+        $events->trigger('finish', $event); 
         return $response; 
     }

Comments

Attaching to the 'dispatch' event with a negative priority value should give you the same result. The only difference will be that the event will always fire, regardless of whether a Response object was returned...however, you could work around this by checking for that inside your callback.

That doesn't work for me, I've tried various negative values with no success.

I've submitted a pull request that will fix the issue. I also identified an additional location where "finish" should be triggered.

https://github.com/zendframework/zf2/pull/828

Patch merged