From 9d33ae6d49ae471d751f467c794c3311fb7c7036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Fri, 23 Sep 2016 23:57:23 +0200 Subject: [PATCH] FEATURE: move default Handler::render() into parent class --- app/Handlers/Handler.php | 14 +++++++++++++ modules/Blog/Article/Handlers/Article.php | 2 +- .../Blog/ArticleList/Handlers/ArticleList.php | 2 +- modules/ContactForm/Handlers/ContactForm.php | 16 --------------- modules/Gallery/Handlers/Gallery.php | 11 +++++----- modules/StaticPages/Handlers/StaticPage.php | 13 ------------ templates/Jednostrankovka/Handler.php | 20 ------------------- 7 files changed, 21 insertions(+), 57 deletions(-) diff --git a/app/Handlers/Handler.php b/app/Handlers/Handler.php index 63ddab59..06a29ae4 100644 --- a/app/Handlers/Handler.php +++ b/app/Handlers/Handler.php @@ -2,6 +2,7 @@ namespace App\Handlers; use App\Handlers\Contracts\AppHandler; +use App\Http\Controllers\Controller; use App\Models\Content; /** @@ -29,6 +30,19 @@ abstract class Handler extends BaseHandler implements AppHandler return History::class; } + /** + * Render given module into visitor area. + * + * @param Content $content DB model from table contents + * @param array $parameters parameters used for modifications/custom settings of given model + * + * @return mixed + */ + public function render(Content $content, $parameters) + { + return Controller::VisitorsView($content->template, ['page' => $content, 'extra' => $parameters]); + } + public static function getExtendedFormSections() { return [ diff --git a/modules/Blog/Article/Handlers/Article.php b/modules/Blog/Article/Handlers/Article.php index 20ede6d3..047be96b 100644 --- a/modules/Blog/Article/Handlers/Article.php +++ b/modules/Blog/Article/Handlers/Article.php @@ -31,7 +31,7 @@ class Article extends Handler ->get(); } - return Controller::VisitorsView($content->template, ['page' => $content]); + return Controller::VisitorsView($content->template, ['page' => $content, 'extra' => $parameters]); } public static function getExtendedFormInputsCreate() diff --git a/modules/Blog/ArticleList/Handlers/ArticleList.php b/modules/Blog/ArticleList/Handlers/ArticleList.php index 555464cf..84bdbcfe 100644 --- a/modules/Blog/ArticleList/Handlers/ArticleList.php +++ b/modules/Blog/ArticleList/Handlers/ArticleList.php @@ -98,7 +98,7 @@ class ArticleList extends Handler $articles = $articles->orderBy('created_at', 'DESC') ->paginate(20); - return Controller::VisitorsView($content->template, ['page' => $content, 'articles' => $articles]); + return Controller::VisitorsView($content->template, ['page' => $content, 'articles' => $articles, 'extra' => $parameters]); } public static function getModuleId() diff --git a/modules/ContactForm/Handlers/ContactForm.php b/modules/ContactForm/Handlers/ContactForm.php index 4c7c4a85..1ff3bedb 100644 --- a/modules/ContactForm/Handlers/ContactForm.php +++ b/modules/ContactForm/Handlers/ContactForm.php @@ -11,21 +11,6 @@ use App\Models\User; class ContactForm extends Handler { - /** - * Render given module into visitor area. - * - * @param Content $content DB model from table contents - * @param array $parameters parameters used for modifications/custom settings of given model - * - * @return mixed - */ - public function render(Content $content, $parameters) - { - $content->module_settings = json_decode($content->module_settings); - - return Controller::VisitorsView($content->template, ['page' => $content]); - } - public static function getHistoryHandler() { return ContactFormHistory::class; @@ -174,7 +159,6 @@ class ContactForm extends Handler */ public static function install() { - // TODO: Implement install() method. } /** diff --git a/modules/Gallery/Handlers/Gallery.php b/modules/Gallery/Handlers/Gallery.php index 59a1f502..4f911737 100644 --- a/modules/Gallery/Handlers/Gallery.php +++ b/modules/Gallery/Handlers/Gallery.php @@ -28,11 +28,6 @@ class Gallery implements AppHandler */ public function render(Content $content, $parameters) { - // if settings is still string, convert it into object - if (is_string($content->module_settings)) { - $content->module_settings = json_decode($content->module_settings); - } - // get directory ID $directoryId = $content->module_settings->directoryId; @@ -42,7 +37,11 @@ class Gallery implements AppHandler ->get(); // render content - return Controller::VisitorsView($content->template, ['images' => $images, 'page' => $content]); + return Controller::VisitorsView($content->template, [ + 'images' => $images, + 'page' => $content, + 'extra' => $parameters + ]); } public static function getHistoryHandler() diff --git a/modules/StaticPages/Handlers/StaticPage.php b/modules/StaticPages/Handlers/StaticPage.php index 011f7d56..6c8607ce 100644 --- a/modules/StaticPages/Handlers/StaticPage.php +++ b/modules/StaticPages/Handlers/StaticPage.php @@ -33,19 +33,6 @@ class StaticPage extends Handler return $moduleId; } - /** - * Render given module into visitor area. - * - * @param Content $content DB model from table contents - * @param array $parameters parameters used for modifications/custom settings of given model - * - * @return mixed - */ - public function render(Content $content, $parameters) - { - return Controller::VisitorsView($content->template, ['page' => $content]); - } - /** * Does given module manage content? Or is it just module with widgets/something internal/something absolutely else? * diff --git a/templates/Jednostrankovka/Handler.php b/templates/Jednostrankovka/Handler.php index b272bf2c..0be5dace 100644 --- a/templates/Jednostrankovka/Handler.php +++ b/templates/Jednostrankovka/Handler.php @@ -10,26 +10,6 @@ use Templates\Base\OnePage\Handlers\OnePage; class Handler extends OnePage { - public static function registerAdminMenu(User $user) - { - parent::registerAdminMenu($user); - - $menu = \Menu::instance('mainMenu'); - - $menu->dropdown(trans('template::admin/mainMenu.templateName'), function ($sub) { - $sub->route('template.setHomepage', trans('template::admin/mainMenu.setHomepage'), [], 1, ['icon' => 'fa fa-fw fa-home']); - }, 20, ['icon' => 'fa fa-fw fa-send']); - - } - - /** - * Prepare Content object to be rendered using Blade template - * - * @param Content $content - */ - public static function beforeRender(Content & $content) - { - } /** * Modify input data into format which can be understood by edit template