From be81834aad51979021ef97de6c4c32e45d5e83e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kv=C3=A1=C4=8Dek?= Date: Tue, 16 Aug 2016 13:20:07 +0200 Subject: [PATCH] FEATURE: add stub of module for comments --- modules/Blog/Comments/Config/config.php | 12 +++ modules/Blog/Comments/Entities/.gitkeep | 0 modules/Blog/Comments/Handlers/Comments.php | 37 ++++++++ .../Controllers/ArticleListController.php | 12 +++ modules/Blog/Comments/Http/routes.php | 6 ++ .../Providers/CommentsServiceProvider.php | 89 +++++++++++++++++++ .../Comments/Resources/lang/en/module.php | 6 ++ modules/Blog/Comments/start.php | 15 ++++ 8 files changed, 177 insertions(+) create mode 100644 modules/Blog/Comments/Config/config.php create mode 100644 modules/Blog/Comments/Entities/.gitkeep create mode 100644 modules/Blog/Comments/Handlers/Comments.php create mode 100644 modules/Blog/Comments/Http/Controllers/ArticleListController.php create mode 100644 modules/Blog/Comments/Http/routes.php create mode 100644 modules/Blog/Comments/Providers/CommentsServiceProvider.php create mode 100644 modules/Blog/Comments/Resources/lang/en/module.php create mode 100644 modules/Blog/Comments/start.php diff --git a/modules/Blog/Comments/Config/config.php b/modules/Blog/Comments/Config/config.php new file mode 100644 index 00000000..248333ab --- /dev/null +++ b/modules/Blog/Comments/Config/config.php @@ -0,0 +1,12 @@ + 'Comments', + 'translatedName' => 'comments::module.name', + 'translatedDescription' => 'comments::module.description', + 'alias' => 'blog-comments', + 'handler' => \Modules\Blog\Comments\Handlers\Comments::class, + 'providers' => [\Modules\Blog\Comments\Providers\CommentsServiceProvider::class], + 'files' => ['start.php'], + 'order' => 0, +]; \ No newline at end of file diff --git a/modules/Blog/Comments/Entities/.gitkeep b/modules/Blog/Comments/Entities/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/modules/Blog/Comments/Handlers/Comments.php b/modules/Blog/Comments/Handlers/Comments.php new file mode 100644 index 00000000..b2674d0d --- /dev/null +++ b/modules/Blog/Comments/Handlers/Comments.php @@ -0,0 +1,37 @@ +dropdown(trans('comments::module.name'), function ($sub) { + $sub->route('comments.overview', trans('comments::module.overview'), [], 10, ['icon' => 'fa fa-fw fa-commenting-o']); + }, 10, ['icon' => 'fa fa-fw fa-comments-o']); + } +} \ No newline at end of file diff --git a/modules/Blog/Comments/Http/Controllers/ArticleListController.php b/modules/Blog/Comments/Http/Controllers/ArticleListController.php new file mode 100644 index 00000000..33ad274f --- /dev/null +++ b/modules/Blog/Comments/Http/Controllers/ArticleListController.php @@ -0,0 +1,12 @@ + 'web', 'prefix' => 'comments', 'namespace' => 'Modules\Blog\Comments\Http\Controllers'], function() +{ + Route::get('/', 'CommentsController@index')->name('comments.overview'); +}); \ No newline at end of file diff --git a/modules/Blog/Comments/Providers/CommentsServiceProvider.php b/modules/Blog/Comments/Providers/CommentsServiceProvider.php new file mode 100644 index 00000000..adb026f2 --- /dev/null +++ b/modules/Blog/Comments/Providers/CommentsServiceProvider.php @@ -0,0 +1,89 @@ +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('comments.php')]); + $this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'comments'); + } + + /** + * Register views. + * + * @return void + */ + public function registerViews() + { + $viewPath = base_path('resources/views/modules/comments'); + $sourcePath = __DIR__.'/../Resources/views'; + + $this->publishes([$sourcePath => $viewPath]); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/comments'; + }, \Config::get('view.paths')), [$sourcePath]), 'comments'); + } + + /** + * Register translations. + * + * @return void + */ + public function registerTranslations() + { + $langPath = base_path('resources/lang/modules/comments'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'comments'); + } else { + $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'comments'); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + +} diff --git a/modules/Blog/Comments/Resources/lang/en/module.php b/modules/Blog/Comments/Resources/lang/en/module.php new file mode 100644 index 00000000..e83dd573 --- /dev/null +++ b/modules/Blog/Comments/Resources/lang/en/module.php @@ -0,0 +1,6 @@ + 'Comments', + 'description' => "Bring comment support to blog module", + 'overview' => 'All comments' +]; \ No newline at end of file diff --git a/modules/Blog/Comments/start.php b/modules/Blog/Comments/start.php new file mode 100644 index 00000000..7be329cb --- /dev/null +++ b/modules/Blog/Comments/start.php @@ -0,0 +1,15 @@ +