/**
* Parse a widget straight from the template, rather than adding it through pages.
* syntax: {{ parsewidget($module, $action, $id) }}
*
* @internal if your widget outputs random data you should cache it inside the widget
* Fork checks the output and if the output of the widget is random it will loop until the random data
* is the same as in the previous iteration
*
* @param string $module The module whose module we want to execute.
* @param string $action The action to execute.
* @param string $id The widget id (saved in data-column).
*
* @return null|string
* @throws Exception
*/
public static function parseWidget($module, $action, $id = null)
{
// create new widget instance and return parsed content
$extra = FrontendBlockWidget::getForId(FrontendModel::get('kernel'), $module, $action, $id);
// set parseWidget because we will need it to skip setting headers in the display
FrontendModel::getContainer()->set('parseWidget', true);
try {
$extra->execute();
$content = $extra->getContent();
FrontendModel::getContainer()->set('parseWidget', null);
return $content;
} catch (Exception $e) {
// if we are debugging, we want to see the exception
if (FrontendModel::getContainer()->getParameter('kernel.debug')) {
throw $e;
}
return;
}
}