src/Widget/BaseWidget.php
/**
     * Actual method that 'runs' the widget and returns the output. For reasons
     * of extensibility: Do not call directly, but call `$widget()` to invoke.
     */
Actual method that 'runs' the widget and returns the output. For reasons
of extensibility: Do not call directly, but call `$widget()` to invoke.
Actual method that ' runs ' the widget and returns the output . For reasons of extensibility : Do not call directly but call ` $widget () ` to invoke .
protected function run(array $params = []): ?string
    {
        if (array_key_exists('template', $params)) {
            $this->setTemplate($params['template']);
        }
        $params['extension'] = $this->extension;
        $params['widget'] = $this;
        if ($this instanceof TwigAwareInterface) {
            $this->addTwigLoader();
            try {
                $output = $this->getTwig()->render($this->getTemplate(), $params);
            } catch (LoaderError $e) {
                $output = "<div style='border: 1px solid #666; background-color: #FCF8E3; padding: 0.5rem;'><mark><strong>";
                $output .= sprintf("Could not render extension '%s'.</strong></mark><br>", $this->getName());
                $output .= sprintf('<code>%s</code><br>', $e->getMessage());
                $output .= sprintf('Did you mean to use <code>@%s/%s</code> instead?</mark></div>', $this->getSlug(), basename($this->getTemplate()));
            }
        } else {
            $output = $this->getTemplate();
        }
        return sprintf(
            '<div class="widget" id="widget-%s" name="%s">%s</div>',
            $this->getSlug(),
            $this->getName(),
            $output
        );
    }
protected function run ( array $ params = [ ] ) : ? string { if ( array_key_exists ( 'template' , $ params ) ) { $ this -> setTemplate ( $ params [ 'template' ] ) ; } $ params [ 'extension' ] = $ this -> extension ; $ params [ 'widget' ] = $ this ; if ( $ this instanceof TwigAwareInterface ) { $ this -> addTwigLoader ( ) ; try { $ output = $ this -> getTwig ( ) -> render ( $ this -> getTemplate ( ) , $ params ) ; } catch ( LoaderError $ e ) { $ output = " <div style='border: 1px solid #666; background-color: #FCF8E3; padding: 0.5rem;'><mark><strong> " ; $ output .= sprintf ( " Could not render extension '%s'.</strong></mark><br> " , $ this -> getName ( ) ) ; $ output .= sprintf ( '<code>%s</code><br>' , $ e -> getMessage ( ) ) ; $ output .= sprintf ( 'Did you mean to use <code>@%s/%s</code> instead?</mark></div>' , $ this -> getSlug ( ) , basename ( $ this -> getTemplate ( ) ) ) ; } } else { $ output = $ this -> getTemplate ( ) ; } return sprintf ( '<div class="widget" id="widget-%s" name="%s">%s</div>' , $ this -> getSlug ( ) , $ this -> getName ( ) , $ output ) ; }
Actual method that 'runs' the widget and returns the output.
Actual method that ' runs ' the widget and returns the output .
// Extension is set, and needs to be available in the template