Bolt\Asset\Widget\Queue::getHtml PHP Method

getHtml() protected method

Get the HTML content from the widget.
protected getHtml ( Bolt\Asset\Widget\WidgetAssetInterface $widget ) : string
$widget Bolt\Asset\Widget\WidgetAssetInterface
return string
    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;
    }