59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
namespace App\Widgets\HtmlCode\Presenters;
|
|
|
|
use App\Models\Widget;
|
|
use App\Models\WidgetType;
|
|
use App\Widgets\Contracts\WidgetRenderer;
|
|
|
|
class HtmlCode implements WidgetRenderer
|
|
{
|
|
/**
|
|
* Method used for displaying widget.
|
|
*
|
|
* This method renders some HTML code for displaying.
|
|
*
|
|
* @param Widget $widget
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function render(Widget $widget)
|
|
{
|
|
$settings = $widget->settings;
|
|
$code = '
|
|
<div class="html-code-widget ' . $widget->container_class . '">
|
|
' . $settings->code . '
|
|
</div>';
|
|
|
|
return $code;
|
|
}
|
|
|
|
/**
|
|
* Display form for creating new instance of widget
|
|
*
|
|
* @param WidgetType $type
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function renderAddForm(WidgetType $type)
|
|
{
|
|
return view('admin.widgets.htmlCode.new', [
|
|
'type' => $type,
|
|
'widget' => new Widget(),
|
|
'settings' => new \stdClass()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Display form for editing already existing widget
|
|
*
|
|
* @param Widget $widget
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public static function renderEditForm(Widget $widget)
|
|
{
|
|
$settings = $widget->settings;
|
|
return view('admin.widgets.htmlCode.edit', ['widget' => $widget, 'settings' => $settings]);
|
|
}
|
|
}
|