FIX: fix minor bugs in blog module
This commit is contained in:
@@ -11,7 +11,8 @@ class Comment extends Model
|
|||||||
'content_id',
|
'content_id',
|
||||||
'content',
|
'content',
|
||||||
'email',
|
'email',
|
||||||
'name'
|
'name',
|
||||||
|
'approved'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function author()
|
public function author()
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ class CreateNewComment extends Controller
|
|||||||
'content_id' => $article->id,
|
'content_id' => $article->id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'content' => $content
|
'content' => $content,
|
||||||
|
'approved' => !is_null($user)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// fire event about new comment
|
// fire event about new comment
|
||||||
|
|||||||
@@ -1,109 +1,91 @@
|
|||||||
<?php namespace Modules\Blog\ArticleList\Providers;
|
<?php namespace Modules\Blog\ArticleList\Providers;
|
||||||
|
|
||||||
use App\Handlers\Registrators\TemplateRegistrator;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use InvalidArgumentException;
|
|
||||||
use Modules\Blog\ArticleList\Handlers\ArticleList;
|
|
||||||
|
|
||||||
class ArticleListServiceProvider extends ServiceProvider {
|
class ArticleListServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Indicates if loading of the provider is deferred.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $defer = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if loading of the provider is deferred.
|
* Boot the application events.
|
||||||
*
|
*
|
||||||
* @var bool
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected $defer = false;
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerTranslations();
|
||||||
|
$this->registerConfig();
|
||||||
|
$this->registerViews();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boot the application events.
|
* Register the service provider.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->registerTranslations();
|
}
|
||||||
$this->registerConfig();
|
|
||||||
$this->registerViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the service provider.
|
* Register config.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function register()
|
protected function registerConfig()
|
||||||
{
|
{
|
||||||
}
|
$this->publishes([__DIR__ . '/../Config/config.php' => config_path('articlelist.php')]);
|
||||||
|
$this->mergeConfigFrom(__DIR__ . '/../Config/config.php', 'articlelist');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register config.
|
* Register views.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function registerConfig()
|
public function registerViews()
|
||||||
{
|
{
|
||||||
$this->publishes([__DIR__.'/../Config/config.php' => config_path('articlelist.php')]);
|
$viewPath = base_path('resources/views/modules/articlelist');
|
||||||
$this->mergeConfigFrom(__DIR__.'/../Config/config.php', 'articlelist');
|
$sourcePath = __DIR__ . '/../Resources/views';
|
||||||
}
|
if (!is_dir($sourcePath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
$this->publishes([$sourcePath => $viewPath]);
|
||||||
* 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');
|
||||||
|
}
|
||||||
|
|
||||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
/**
|
||||||
return $path . '/modules/articlelist';
|
* Register translations.
|
||||||
}, \Config::get('view.paths')), [$sourcePath]), 'articlelist');
|
*
|
||||||
|
* @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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $registrator TemplateRegistrator
|
* Get the services provided by the provider.
|
||||||
*/
|
*
|
||||||
try {
|
* @return array
|
||||||
// setup some global variables
|
*/
|
||||||
$registrator = $this->app->make('registerTemplateDir');
|
public function provides()
|
||||||
$registrator->setBaseDirectory('resources/views/modules/articlelist/visitor');
|
{
|
||||||
$registrator->setNamespace('articlelist');
|
return array ();
|
||||||
$registrator->setModuleId(ArticleList::getModuleId());
|
}
|
||||||
|
|
||||||
// register path with current template name
|
|
||||||
$registrator->register(config('app.theme'), 'articlelist::module.templatePath');
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
// ignore this exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user