We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How get content in afterExecuteRoute method?

I need save content in memcached. How get volt rendered content in afterExecuteRoute method?

Like this perhaps:

public functin afterExecuteRoute(Event $event, Dispatcher $dispatcher)
{
    $content = $dispatcher->getReturnedValue()->getContent();
}


25.0k

Fatal error: Call to a member function getContent()

Wojciech Ślawski, you use phalcon 2+?

edited Aug '16

Yes. What you return in controller action ? Not response ? It should work if you return:

return $responset->setContent('xyz');

Or you use automatic rendering, or return $this->view->pick() or return $this->view->render()

What exactly $dispatcher->getReturnedValue() return ?

If this is not working then try:

$content = $dispatcher->getDI()->get('response')->getContent();