Skip to content

Instantly share code, notes, and snippets.

@zyphlar
Created February 25, 2016 19:22
Show Gist options
  • Save zyphlar/ee268d646152cd1f5494 to your computer and use it in GitHub Desktop.
Save zyphlar/ee268d646152cd1f5494 to your computer and use it in GitHub Desktop.
after-controller-response hooks in Symfony2
<?php
public function myPostControllerFunction($someObject) {
$dispatcher = $this->get('event_dispatcher');
$logger = $this->get('logger');
$dispatcher->addListener('kernel.terminate', function ($event) use ($logger, $someObject) {
$logger->warning('This log entry was generated after Kernel Terminate and was passed an object of class: '.get_class($someObject));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment