protected function getHtml(WidgetAssetInterface $widget)
{
$key = 'widget_' . $widget->getKey();
if ($html = $this->cache->fetch($key)) {
return $html;
}
/** @var \Exception $e */
$e = null;
set_error_handler(function ($errno, $errstr) use(&$e) {
return $e = new \Exception($errstr, $errno);
});
// Get the HTML from object cast and rethrow an exception if present
$html = (string) $widget;
restore_error_handler();
if ($e instanceof \Exception) {
throw $e;
}
if ($widget->getCacheDuration() !== null) {
$this->cache->save($key, $html, $widget->getCacheDuration());
}
return $html;
}