FEATURE: add basic article list

This commit is contained in:
Michal Kváček
2016-09-07 00:47:57 +02:00
parent 5b7b81ff4d
commit 44677aea78
27 changed files with 173 additions and 64 deletions
@@ -1,6 +1,9 @@
<?php namespace Modules\Blog\ArticleList\Providers;
use App\Handlers\Registrators\TemplateRegistrator;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
use Modules\Blog\ArticleList\Handlers\ArticleList;
class ArticleListServiceProvider extends ServiceProvider {
@@ -30,7 +33,6 @@ class ArticleListServiceProvider extends ServiceProvider {
*/
public function register()
{
//
}
/**
@@ -40,12 +42,8 @@ class ArticleListServiceProvider extends ServiceProvider {
*/
protected function registerConfig()
{
$this->publishes([
__DIR__.'/../Config/config.php' => config_path('articlelist.php'),
]);
$this->mergeConfigFrom(
__DIR__.'/../Config/config.php', 'articlelist'
);
$this->publishes([__DIR__.'/../Config/config.php' => config_path('articlelist.php')]);
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'articlelist');
}
/**
@@ -56,16 +54,30 @@ class ArticleListServiceProvider extends ServiceProvider {
public function registerViews()
{
$viewPath = base_path('resources/views/modules/articlelist');
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([
$sourcePath => $viewPath
]);
$this->publishes([$sourcePath => $viewPath]);
$this->loadViewsFrom(array_merge(array_map(function ($path) {
return $path . '/modules/articlelist';
}, \Config::get('view.paths')), [$sourcePath]), 'articlelist');
/**
* @var $registrator TemplateRegistrator
*/
try {
// setup some global variables
$registrator = $this->app->make('registerTemplateDir');
$registrator->setBaseDirectory('resources/views/modules/articlelist/visitor');
$registrator->setNamespace('articlelist');
$registrator->setModuleId(ArticleList::getModuleId());
// register path with current template name
$registrator->register(config('app.theme'), 'articlelist::module.templatePath');
} catch (InvalidArgumentException $e) {
// ignore this exception
}
}
/**