simplify to add widgets via plugin (#1308)
This commit is contained in:
@@ -11,7 +11,6 @@ namespace App\Widget\Renderer;
|
||||
|
||||
use App\Widget\Type\SimpleWidget;
|
||||
use App\Widget\WidgetInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
class SimpleWidgetRenderer extends AbstractTwigRenderer
|
||||
{
|
||||
@@ -20,11 +19,18 @@ class SimpleWidgetRenderer extends AbstractTwigRenderer
|
||||
return $widget instanceof SimpleWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SimpleWidget $widget
|
||||
* @param array $options
|
||||
* @return string
|
||||
* @throws \ReflectionException
|
||||
* @throws \Twig\Error\LoaderError
|
||||
* @throws \Twig\Error\RuntimeError
|
||||
* @throws \Twig\Error\SyntaxError
|
||||
*/
|
||||
public function render(WidgetInterface $widget, array $options = []): string
|
||||
{
|
||||
$name = (new ReflectionClass($widget))->getShortName();
|
||||
|
||||
return $this->renderTemplate(sprintf('widget/widget-%s.html.twig', strtolower($name)), [
|
||||
return $this->renderTemplate($widget->getTemplateName(), [
|
||||
'data' => $widget->getData($options),
|
||||
'options' => $widget->getOptions($options),
|
||||
'title' => $widget->getTitle(),
|
||||
|
||||
Reference in New Issue
Block a user