FEATURE: prepare class structure for menu widget.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace App\Handlers\Registrators;
|
||||
|
||||
use App\Widgets\Contracts\MenuExtensionHandler;
|
||||
|
||||
class MenuExtensionRegistrator {
|
||||
|
||||
protected $menuExtensions;
|
||||
|
||||
/**
|
||||
* @param MenuExtensionHandler $handler
|
||||
*/
|
||||
public function register(MenuExtensionHandler $handler) {
|
||||
$this->menuExtensions[] = $handler;
|
||||
}
|
||||
|
||||
public function get(){
|
||||
return $this->menuExtensions;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Handlers\Registrators\MenuExtensionRegistrator;
|
||||
use App\Handlers\Registrators\SearchEngineRegistrator;
|
||||
use App\Handlers\Registrators\SettingsExtensionRegistrator;
|
||||
use App\Handlers\Registrators\TemplateRegistrator;
|
||||
@@ -11,6 +12,8 @@ use App\Handlers\Search\Files;
|
||||
use App\Handlers\Search\Presenters\AdminContent as AdminContentPresenter;
|
||||
use App\Handlers\Search\Presenters\AdminFiles;
|
||||
use App\Widgets\HtmlCode\HtmlCode;
|
||||
use App\Widgets\Menu\Extensions\URL;
|
||||
use App\Widgets\Menu\Menu;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -49,6 +52,10 @@ class AppServiceProvider extends ServiceProvider
|
||||
return new WidgetRegistrator($app);
|
||||
});
|
||||
|
||||
$this->app->singleton('registerMenuExtension', function ($app) {
|
||||
return new MenuExtensionRegistrator($app);
|
||||
});
|
||||
|
||||
// create registrator for template directories
|
||||
$this->app->singleton('registerTemplateDir', function ($app) {
|
||||
return new TemplateRegistrator($app);
|
||||
@@ -75,6 +82,11 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
// register all available widgets
|
||||
$registrator->register(HtmlCode::class);
|
||||
$registrator->register(Menu::class);
|
||||
|
||||
// register some menu extensions
|
||||
$menuExtensions = $this->app->make('registerMenuExtension');
|
||||
$menuExtensions->register(new URL());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace App\Widgets\Contracts;
|
||||
|
||||
interface MenuExtensionHandler {
|
||||
|
||||
public static function getPossibleValues();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace App\Widgets\Menu\Extensions;
|
||||
|
||||
use App\Widgets\Contracts\MenuExtensionHandler;
|
||||
|
||||
class URL implements MenuExtensionHandler {
|
||||
public static function getPossibleValues()
|
||||
{
|
||||
// TODO: Implement getPossibleValues() method.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace App\Widgets\Menu;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Widgets\Contracts\WidgetRenderer;
|
||||
use App\Widgets\Widget;
|
||||
|
||||
class Menu extends Widget
|
||||
{
|
||||
/**
|
||||
* Name getter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getName()
|
||||
{
|
||||
return 'widgets/menu.name';
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription()
|
||||
{
|
||||
return 'widgets/menu.description';
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for presenter/renderer of this widget
|
||||
*
|
||||
* @return WidgetRenderer
|
||||
*/
|
||||
public static function getPresenter()
|
||||
{
|
||||
return Presenters\Menu::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \App\Models\Widget $widget
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function save(\App\Models\Widget $widget, Request $request)
|
||||
{
|
||||
// TODO: Implement save() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for installing given widget
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function install()
|
||||
{
|
||||
// TODO: Implement install() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for uninstalling widget
|
||||
*/
|
||||
public static function uninstall()
|
||||
{
|
||||
// TODO: Implement uninstall() method.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace App\Widgets\Menu\Presenters;
|
||||
|
||||
use App\Models\Widget;
|
||||
use App\Models\WidgetType;
|
||||
use App\Widgets\Contracts\WidgetRenderer;
|
||||
|
||||
class Menu implements WidgetRenderer
|
||||
{
|
||||
/**
|
||||
* Method used for displaying widget.
|
||||
*
|
||||
* This method renders some HTML code for displaying.
|
||||
*
|
||||
* @param object $settings
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function render($settings)
|
||||
{
|
||||
// TODO: Implement render() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form for creating new instance of widget
|
||||
*
|
||||
* @param WidgetType $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderAddForm(WidgetType $type)
|
||||
{
|
||||
// TODO: Implement renderAddForm() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form for editing already existing widget
|
||||
*
|
||||
* @param Widget $widget
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function renderEditForm(Widget $widget)
|
||||
{
|
||||
// TODO: Implement renderEditForm() method.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return [
|
||||
'name' => 'Menu',
|
||||
'description' => 'User defined menu'
|
||||
];
|
||||
Reference in New Issue
Block a user