Hey, what is proper way to attach to 'application:beforeSendResponse' event?
This is what I'm doing, but die("weee"); never gets executed. If I uncomment that another die it will get executed.
And can list of all default phalcon event be found somewhere? I unable to find them from docments
public function setDI(DiInterface $dependencyInjector)
{
$this->di = $dependencyInjector;
$this->registerEvents($dependencyInjector);
parent::setDI($dependencyInjector); // TODO: Change the autogenerated stub
}
public function getDI()
{
parent::getDI(); // TODO: Change the autogenerated stub
}
private function registerEvents($di) {
$eventManager = $di->getShared("eventsManager");
if (!$eventManager) {
throw new Exception("No events manager");
}
//die("this kills");
$eventManager->attach("application:beforeSendResponse",
function(Event $event, \Phalcon\Mvc\Application $app, ResponseInterface $response) use($di) {
die("weeee");
/** @var Response $response */
$response = $di->getShared("response");
$response->setHeader("flash", json_encode($this->flashes));
}
);
}