FEATURE: add blog module stub
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => 'Articles',
|
||||||
|
'translatedName' => 'article::module.name',
|
||||||
|
'translatedDescription' => 'article::module.description',
|
||||||
|
'alias' => 'blog-article',
|
||||||
|
'handler' => \Modules\Blog\Article\Handlers\Article::class,
|
||||||
|
'providers' => [\Modules\Blog\Article\Providers\ArticleServiceProvider::class],
|
||||||
|
'files' => ['start.php'],
|
||||||
|
'order' => 0,
|
||||||
|
];
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
namespace Modules\Blog\Article\Handlers;
|
||||||
|
|
||||||
|
use App\Enumerations\ModulesHandlerToId;
|
||||||
|
use App\Handlers\Handler;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Content;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class Article 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)
|
||||||
|
{
|
||||||
|
return Controller::VisitorsView($content->template, ['page' => $content]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load some extra data for content management form?
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function loadExtraData(Content $content)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save module-specific values into database
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @internal param Widget $widget
|
||||||
|
*/
|
||||||
|
public static function createNew(Content &$content, Request $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 $revisionID string ID of revision used
|
||||||
|
*
|
||||||
|
* @return int number of edited fields
|
||||||
|
*/
|
||||||
|
public static function edit(Content &$content, Request $request, $revisionID)
|
||||||
|
{
|
||||||
|
// TODO: Implement edit() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public static function registerAdminMenu(User $user)
|
||||||
|
{
|
||||||
|
parent::registerAdminMenu($user);
|
||||||
|
|
||||||
|
$menu = \Menu::instance('mainMenu');
|
||||||
|
|
||||||
|
$menu->dropdown(trans('article::module.name'), function ($sub) {
|
||||||
|
$sub->route('article.new', trans('article::article.new'), [], 10, ['icon' => 'fa fa-fw fa-pencil']);
|
||||||
|
$sub->route('article.overview', trans('article::article.overview'), [], 30, ['icon' => 'fa fa-fw fa-book']);
|
||||||
|
}, 10, ['icon' => 'fa fa-fw fa-book']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModuleId()
|
||||||
|
{
|
||||||
|
$handler = config('article.handler');
|
||||||
|
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||||
|
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
|
||||||
|
|
||||||
|
return $moduleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install module
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function install()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Route::group([
|
||||||
|
'middleware' => 'web',
|
||||||
|
'prefix' => 'article',
|
||||||
|
'namespace' => 'Modules\Blog\Article\Http\Controllers'
|
||||||
|
], function () {
|
||||||
|
Route::get('/', 'CategoriesOverview@getOverview')
|
||||||
|
->name('article.overview');
|
||||||
|
|
||||||
|
Route::get('/new', 'CreateNewCategory@getNew')
|
||||||
|
->name('article.new');
|
||||||
|
|
||||||
|
Route::post('/new', 'CreateNewCategory@postNew')
|
||||||
|
->name('article.postNew');
|
||||||
|
|
||||||
|
Route::get('/edit/{id}', 'EditCategory@getEdit')
|
||||||
|
->name('article.edit');
|
||||||
|
|
||||||
|
Route::post('/edit/{id}', 'EditCategory@postEdit')
|
||||||
|
->name('article.postEdit');
|
||||||
|
|
||||||
|
Route::get('/delete/{id}', 'EditCategory@delete')
|
||||||
|
->name('article.delete');
|
||||||
|
});
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<?php namespace Modules\Blog\Article\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Pingpong\Modules\Facades\Module;
|
||||||
|
|
||||||
|
class ArticleServiceProvider extends ServiceProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if loading of the provider is deferred.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $defer = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerTranslations();
|
||||||
|
$this->registerConfig();
|
||||||
|
$this->registerViews();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register config.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function registerConfig()
|
||||||
|
{
|
||||||
|
$this->publishes([
|
||||||
|
__DIR__.'/../Config/config.php' => config_path('article.php'),
|
||||||
|
]);
|
||||||
|
$this->mergeConfigFrom(
|
||||||
|
__DIR__.'/../Config/config.php', 'article'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register views.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerViews()
|
||||||
|
{
|
||||||
|
$viewPath = base_path('resources/views/modules/article');
|
||||||
|
$sourcePath = __DIR__.'/../Resources/views';
|
||||||
|
|
||||||
|
$this->publishes([$sourcePath => $viewPath]);
|
||||||
|
|
||||||
|
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||||
|
return $path . '/modules/article';
|
||||||
|
}, \Config::get('view.paths')), [$sourcePath]), 'article');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register translations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerTranslations()
|
||||||
|
{
|
||||||
|
$langPath = base_path('resources/lang/modules/article');
|
||||||
|
|
||||||
|
if (is_dir($langPath)) {
|
||||||
|
$this->loadTranslationsFrom($langPath, 'article');
|
||||||
|
} else {
|
||||||
|
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'article');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provides()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'name' => 'Article',
|
||||||
|
'description' => 'Base submodule for blog'
|
||||||
|
];
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "pingpong-modules/article",
|
||||||
|
"description": "",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Pingpong Labs",
|
||||||
|
"email": "pingpong.labs@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Modules\\Article\\": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Namespaces And Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When a module starting, this file will executed automatically. This helps
|
||||||
|
| to register some namespaces like translator or view. Also this file
|
||||||
|
| will load the routes file for each module. You may also modify
|
||||||
|
| this file as you want.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
require __DIR__ . '/Http/routes.php';
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => 'ArticleList'
|
||||||
|
];
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php namespace Modules\Blog\ArticleList\Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ArticleListDatabaseSeeder extends Seeder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
Model::unguard();
|
||||||
|
|
||||||
|
// $this->call("OthersTableSeeder");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php namespace Modules\Blog\ArticleList\Http\Controllers;
|
||||||
|
|
||||||
|
use Pingpong\Modules\Routing\Controller;
|
||||||
|
|
||||||
|
class ArticleListController extends Controller {
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('articlelist::index');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Route::group(['middleware' => 'web', 'prefix' => 'articlelist', 'namespace' => 'Modules\Blog\ArticleList\Http\Controllers'], function()
|
||||||
|
{
|
||||||
|
Route::get('/', 'ArticleListController@index');
|
||||||
|
});
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php namespace Modules\Blog\ArticleList\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class ArticleListServiceProvider extends ServiceProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if loading of the provider is deferred.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $defer = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the application events.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerTranslations();
|
||||||
|
$this->registerConfig();
|
||||||
|
$this->registerViews();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register config.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function registerConfig()
|
||||||
|
{
|
||||||
|
$this->publishes([
|
||||||
|
__DIR__.'/../Config/config.php' => config_path('articlelist.php'),
|
||||||
|
]);
|
||||||
|
$this->mergeConfigFrom(
|
||||||
|
__DIR__.'/../Config/config.php', 'articlelist'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register views.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerViews()
|
||||||
|
{
|
||||||
|
$viewPath = base_path('resources/views/modules/articlelist');
|
||||||
|
|
||||||
|
$sourcePath = __DIR__.'/../Resources/views';
|
||||||
|
|
||||||
|
$this->publishes([
|
||||||
|
$sourcePath => $viewPath
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||||
|
return $path . '/modules/articlelist';
|
||||||
|
}, \Config::get('view.paths')), [$sourcePath]), 'articlelist');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register translations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerTranslations()
|
||||||
|
{
|
||||||
|
$langPath = base_path('resources/lang/modules/articlelist');
|
||||||
|
|
||||||
|
if (is_dir($langPath)) {
|
||||||
|
$this->loadTranslationsFrom($langPath, 'articlelist');
|
||||||
|
} else {
|
||||||
|
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'articlelist');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provides()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@extends('articlelist::layouts.master')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<h1>Hello World</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This view is loaded from module: {!! config('articlelist.name') !!}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@stop
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Module ArticleList</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
@yield('content')
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Namespaces And Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When a module starting, this file will executed automatically. This helps
|
||||||
|
| to register some namespaces like translator or view. Also this file
|
||||||
|
| will load the routes file for each module. You may also modify
|
||||||
|
| this file as you want.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
require __DIR__ . '/Http/routes.php';
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'name' => 'Blog',
|
||||||
|
'description' => '',
|
||||||
|
'hasSubmodules' => true,
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user