FEATURE: add another repositories
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
<?php
|
||||
namespace Modules\Blog\Article\Handlers;
|
||||
|
||||
use App\CMS\Enumerations\ModulesHandlerToId;
|
||||
use App\CMS\Contracts\Content\AdvancedContentModifier;
|
||||
use App\CMS\Contracts\Modules\InstallableModule;
|
||||
use App\CMS\Handlers\Contracts\ContentTitles;
|
||||
use App\CMS\Handlers\Handler;
|
||||
use App\Http\Controllers\Admin\Contents\EditContent;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\ActionLogType;
|
||||
use App\Models\ActionLog\ActionLogType;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Module;
|
||||
use App\Models\User;
|
||||
use Modules\Blog\Article\Entities\Comment;
|
||||
|
||||
class Article extends Handler implements ContentTitles
|
||||
class Article extends Handler implements ContentTitles, AdvancedContentModifier, InstallableModule
|
||||
{
|
||||
/**
|
||||
* Render given module into visitor area.
|
||||
@@ -109,22 +111,13 @@ class Article extends Handler implements ContentTitles
|
||||
}
|
||||
|
||||
$blogSubmenu->dropdown(trans('article::module.name'), function ($sub) {
|
||||
$sub->route('content.new', trans('article::article.new'), ['id' => self::getModuleId()], 10, ['icon' => 'fa fa-fw fa-pencil']);
|
||||
$sub->route('content.overview', trans('article::article.overview'), ['id' => self::getModuleId()], 30, ['icon' => 'fa fa-fw fa-book']);
|
||||
$sub->route('content.new', trans('article::article.new'), ['id' => config('article.alias')], 10, ['icon' => 'fa fa-fw fa-pencil']);
|
||||
$sub->route('content.overview', trans('article::article.overview'), ['id' => config('article.alias')], 30, ['icon' => 'fa fa-fw fa-book']);
|
||||
}, 10, ['icon' => 'fa fa-fw fa-book']);
|
||||
|
||||
$blogSubmenu->route('comments.overview', trans('article::module.commentsOverview'), [], 20, ['icon' => 'fa fa-fw fa-commenting-o']);
|
||||
}
|
||||
|
||||
public static function getModuleId()
|
||||
{
|
||||
$handler = config('article.handler');
|
||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
||||
|
||||
return $moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install module
|
||||
*/
|
||||
@@ -153,6 +146,19 @@ class Article extends Handler implements ContentTitles
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls module
|
||||
*
|
||||
* @param Module $module
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public static function uninstall(Module $module)
|
||||
{
|
||||
ActionLogType::whereIn('string_id', ['commentCreated', 'commentDeleted', 'commentApproved'])
|
||||
->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated title for pages overview of given type.
|
||||
*
|
||||
@@ -186,4 +192,38 @@ class Article extends Handler implements ContentTitles
|
||||
{
|
||||
return trans('article::module.editArticle');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called right after content page is marked as deleted
|
||||
*
|
||||
* This method is supposed to clean after "deleted" page.
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function delete(Content $content)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Load some extra data for content management form?
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function loadExtraData(Content $content)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this module support categories?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function supportCategories()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace Modules\Categories\Contracts\Repositories;
|
||||
|
||||
use App\CMS\Contracts\Repositories\BaseRepository;
|
||||
use App\Models\Module;
|
||||
|
||||
interface Category {
|
||||
public function getForModule(Module $module);
|
||||
}
|
||||
@@ -5,7 +5,7 @@ use App\Models\Content\Content;
|
||||
use App\Models\Module;
|
||||
use Franzose\ClosureTable\Models\Entity;
|
||||
|
||||
class Category extends Entity implements CategoryInterface
|
||||
class Category extends Entity
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace Modules\Categories\Entities;
|
||||
|
||||
use Franzose\ClosureTable\Models\ClosureTable;
|
||||
|
||||
class CategoryClosure extends ClosureTable implements CategoryClosureInterface
|
||||
class CategoryClosure extends ClosureTable
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
namespace Modules\Categories\Entities;
|
||||
|
||||
use Franzose\ClosureTable\Contracts\ClosureTableInterface;
|
||||
|
||||
interface CategoryClosureInterface extends ClosureTableInterface
|
||||
{
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace App;namespace Modules\Categories\Entities;
|
||||
use Franzose\ClosureTable\Contracts\EntityInterface;
|
||||
|
||||
interface CategoryInterface extends EntityInterface
|
||||
{
|
||||
}
|
||||
@@ -1,21 +1,11 @@
|
||||
<?php
|
||||
namespace Modules\Categories\Handlers;
|
||||
|
||||
use App\CMS\Enumerations\ModulesHandlerToId;
|
||||
use App\CMS\Handlers\BaseHandler;
|
||||
use App\CMS\Contracts\Modules\BaseModuleHandler;
|
||||
use App\Models\User;
|
||||
|
||||
class Categories extends BaseHandler
|
||||
class Categories implements BaseModuleHandler
|
||||
{
|
||||
public static function getModuleId()
|
||||
{
|
||||
$handler = config('categories.handler');
|
||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
||||
|
||||
return $moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin menu (or multiple ones)
|
||||
*
|
||||
@@ -26,8 +16,6 @@ class Categories extends BaseHandler
|
||||
*/
|
||||
public static function registerAdminMenu(User $user)
|
||||
{
|
||||
parent::registerAdminMenu($user);
|
||||
|
||||
// register links in admin menu
|
||||
$menu = \Menu::instance('mainMenu');
|
||||
$menu->dropdown(trans('categories::categories.name'), function ($sub) {
|
||||
@@ -35,14 +23,4 @@ class Categories extends BaseHandler
|
||||
$sub->route('categories.overview', trans('categories::categories.overview'), [], 30, ['icon' => 'fa fa-fw fa-tags']);
|
||||
}, 55, ['icon' => 'fa fa-fw fa-tags']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Install module
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function install()
|
||||
{
|
||||
// nothing to install
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php namespace Modules\Categories\Providers;
|
||||
<?php
|
||||
namespace Modules\Categories\Providers;
|
||||
|
||||
use App\Providers\ModuleServiceProvider;
|
||||
use Modules\Categories\Contracts\Repositories\Category as ICategory;
|
||||
use Modules\Categories\Repositories\Category as Category;
|
||||
|
||||
class CategoriesServiceProvider extends ModuleServiceProvider
|
||||
{
|
||||
@@ -9,6 +12,13 @@ class CategoriesServiceProvider extends ModuleServiceProvider
|
||||
$this->alias = 'categories';
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
$this->app->bind(ICategory::class, Category::class);
|
||||
}
|
||||
|
||||
protected function setModulePath()
|
||||
{
|
||||
$this->path = __DIR__;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Modules\Categories\Repositories;
|
||||
|
||||
use App\Models\Module;
|
||||
use Modules\Categories\Entities\Category as CategoryModel;
|
||||
use Modules\Categories\Contracts\Repositories\Category as ICategory;
|
||||
use Pingpong\Modules\Facades\Module as ModuleInstance;
|
||||
|
||||
class Category implements ICategory
|
||||
{
|
||||
public function getForModule(Module $module)
|
||||
{
|
||||
$categoryModule = ModuleInstance::get('categories');
|
||||
$categories = [];
|
||||
if ($module->support_categories && !is_null($categoryModule) && $categoryModule->enabled()) {
|
||||
$categories = CategoryModel::where('module_id', $module->id)
|
||||
->get();
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Modules\ContactForm\Handlers;
|
||||
|
||||
use App\CMS\Contracts\Content\AdvancedContentModifier;
|
||||
use App\CMS\Enumerations\ModulesHandlerToId;
|
||||
use App\CMS\Handlers\Contracts\ContentTitles;
|
||||
use App\CMS\Handlers\Handler;
|
||||
@@ -9,7 +10,7 @@ use App\Http\Requests\Request;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\User;
|
||||
|
||||
class ContactForm extends Handler implements ContentTitles
|
||||
class ContactForm extends Handler implements ContentTitles, AdvancedContentModifier
|
||||
{
|
||||
public static function getHistoryHandler()
|
||||
{
|
||||
@@ -152,27 +153,6 @@ class ContactForm extends Handler implements ContentTitles
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install module
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function install()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Load some extra data for content management form?
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function loadExtraData(Content $content)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated title for pages overview of given type.
|
||||
*
|
||||
@@ -206,4 +186,38 @@ class ContactForm extends Handler implements ContentTitles
|
||||
{
|
||||
return trans('contactform::module.editForm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this module support categories?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function supportCategories()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called right after content page is marked as deleted
|
||||
*
|
||||
* This method is supposed to clean after "deleted" page.
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function delete(Content $content)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Load some extra data for content management form?
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function loadExtraData(Content $content)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ namespace Modules\StaticPages\Handlers;
|
||||
use App\CMS\Enumerations\ModulesHandlerToId;
|
||||
use App\CMS\Handlers\Contracts\ContentTitles;
|
||||
use App\CMS\Handlers\Handler;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\User;
|
||||
|
||||
@@ -13,93 +11,16 @@ class StaticPage extends Handler implements ContentTitles
|
||||
{
|
||||
public static function registerAdminMenu(User $user)
|
||||
{
|
||||
parent::registerAdminMenu($user);
|
||||
|
||||
// register links in admin menu
|
||||
$menu = \Menu::instance('mainMenu');
|
||||
$submenu = $menu->whereTitle(trans('admin/mainMenu.contentPages'));
|
||||
|
||||
$submenu->dropdown(trans('staticpages::adminMenu.staticPages'), function ($submenu) use ($user) {
|
||||
$submenu->route('content.new', trans('staticpages::adminMenu.new'), ['moduleId' => self::getModuleId()], 10, ['icon' => 'fa fa-plus']);
|
||||
$submenu->route('content.overview', trans('staticpages::adminMenu.overview'), ['moduleId' => self::getModuleId()], 20, ['icon' => 'fa fa-list']);
|
||||
$submenu->route('content.new', trans('staticpages::adminMenu.new'), ['module' => config('staticpages.alias')], 10, ['icon' => 'fa fa-plus']);
|
||||
$submenu->route('content.overview', trans('staticpages::adminMenu.overview'), ['module' => config('staticpages.alias')], 20, ['icon' => 'fa fa-list']);
|
||||
}, 15, ['icon' => 'fa fa-newspaper-o']);
|
||||
}
|
||||
|
||||
public static function getModuleId()
|
||||
{
|
||||
$handler = config('staticpages.handler');
|
||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
||||
|
||||
return $moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does given module manage content? Or is it just module with widgets/something internal/something absolutely else?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function managesContent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save module-specific values into database
|
||||
*
|
||||
* @param Content $content
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function createNew(Content &$content, Request $request)
|
||||
{
|
||||
// There is nothing more we can save. Static pages are only text saved into database.
|
||||
// This funcionality is already covered in saving content page alone.
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used for editing existing content page.
|
||||
*
|
||||
* Reason why it is separated from createNew() method is simple - we need to save history of changes.
|
||||
*
|
||||
* @param Content $content
|
||||
* @param Request $request
|
||||
* @param string $revisionId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function edit(Content &$content, Request $request, $revisionId)
|
||||
{
|
||||
// There is nothing more we can save. Static pages are only text saved into database.
|
||||
// This funcionality is already covered in saving content page alone.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install module
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function install()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
* Load some extra data for content management form?
|
||||
*
|
||||
* @param Content $content
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function loadExtraData(Content $content)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get translated title for pages overview of given type.
|
||||
*
|
||||
@@ -133,4 +54,24 @@ class StaticPage extends Handler implements ContentTitles
|
||||
{
|
||||
return trans('staticpages::module.editPage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Does given module manage content? Or is it just module with widgets/something internal/something absolutely else?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function managesContent()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this module support categories?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function supportCategories()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user