Search code examples
pluginsjoomlasystem

Joomla4 plugin getBody


In Joomla 3.x versions I use JResponse to get and set the body.

function onAfterRender() {
          $content = JResponse::getBody();
          ...
    }

But in Joomla4 it returns Class 'JResponse' not found. So how to get the body in Joomla4?

Thanks


Solution

  • My cross-posted answer...

    According to the documentation, JApplicationWeb seems to be alive and well in Joomla4.

    since 2.5.0

    note As of 4.0 this class will be abstract

    • The getters:

      JApplicationWeb::getBody()
      

      Or

      JFactory::getApplication()->getBody()
      
    • The setters:

      JApplicationWeb::setBody()
      

      Or

      JFactory::getApplication()->setBody()
      

    Relevant references and examples: