FEATURE #1422: prepare application for registering widgets

This commit is contained in:
Michal Kváček
2016-02-15 12:19:40 +01:00
parent 677acf3dcb
commit da3046c990
10 changed files with 243 additions and 1 deletions
@@ -0,0 +1,12 @@
<?php
namespace App\Widgets\Contracts;
interface AdminDashboardWidget extends PublicWidget
{
/**
* Getter for list of all roles which are allowed to display the widget
*
* @return array
*/
public static function renderForRoles();
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App\Widgets\Contracts;
use App\Http\Requests\Request;
use App\Models\Widget;
interface PublicWidget
{
/**
* Name getter
*
* @return string
*/
public static function getName();
/**
* Getter for description
*
* @return string
*/
public static function getDescription();
/**
* Getter for presenter/renderer of this widget
*
* @return WidgetRenderer
*/
public static function getPresenter();
/**
* @param Widget $widget
* @param Request $request
*
* @return mixed
*/
public static function save(Widget $widget, Request $request);
/**
* Function for installing given widget
*
* @return mixed
*/
public static function install();
/**
* Function for uninstalling widget
*/
public static function uninstall();
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Widgets\Contracts;
use App\Models\Widget;
use App\Models\WidgetType;
interface WidgetRenderer
{
/**
* Method used for displaying widget.
*
* This method renders some HTML code for displaying.
*
* @param object $settings
*
* @return mixed
*/
public static function render($settings);
/**
* Display form for creating new instance of widget
*
* @param WidgetType $type
*
* @return mixed
*/
public static function renderAddForm(WidgetType $type);
/**
* Display form for editing already existing widget
*
* @param Widget $widget
*
* @return mixed
*/
public static function renderEditForm(Widget $widget);
}