This hook allows you to customize the output of a \Contao\Widget
when it is
parsed.
string $buffer
The output buffer for the widget.
\Contao\Widget $widget
The \Contao\Widget
instance.
The (modified) output buffer for the widget.
// src/EventListener/ParseWidgetListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\Widget;
#[AsHook('parseWidget')]
class ParseWidgetListener
{
public function __invoke(string $buffer, Widget $widget): string
{
// Do something …
return $buffer;
}
}