Risposte:
Supponendo che il tuo modulo sia sotto Vendor\Module
Se desideri acquisire l'HTML dalla risposta, puoi dichiarare il tuo evento in etc\<area>\events.xml
(dove si <area>
trova adminhtml
o frontend
):
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_front_send_response_before">
<observer name="vendor_module" instance="Vendor\Module\Model\Observer" shared="false" />
</event>
</config>
Quindi sotto Model\Observer.php
:
<?php
namespace Vendor\Module\Model;
use Magento\Framework\Event\ObserverInterface;
class Observer implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$response = $observer->getEvent()->getData('response');
if (!$response) return;
$body = $response->getBody();
}
}