FEATURE #1394: init static page module

Module is now installed and ready to be used
This commit is contained in:
Michal Kváček
2016-01-27 15:28:41 +01:00
parent 79d5277a13
commit 35a93091ff
5 changed files with 44 additions and 11 deletions
+6
View File
@@ -0,0 +1,6 @@
<?php
namespace App\Handlers;
abstract class Handler {
abstract public function render();
}
+1 -1
View File
@@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Model;
class Module extends Model class Module extends Model
{ {
public $timestamps = true; public $timestamps = false;
protected $fillable = [ protected $fillable = [
'handler', 'handler',
@@ -0,0 +1,11 @@
<?php
namespace Modules\StaticPages\Handlers;
use App\Handlers\Handler;
class StaticPage extends Handler {
public function render()
{
// TODO: Implement render() method.
}
}
@@ -1,5 +1,7 @@
<?php namespace Modules\Staticpages\Providers; <?php namespace Modules\Staticpages\Providers;
use App\Enumerations\Modules;
use App\Models\Module;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class StaticPagesServiceProvider extends ServiceProvider class StaticPagesServiceProvider extends ServiceProvider
@@ -18,6 +20,7 @@ class StaticPagesServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
$this->install();
$this->registerTranslations(); $this->registerTranslations();
$this->registerConfig(); $this->registerConfig();
$this->registerViews(); $this->registerViews();
@@ -40,6 +43,24 @@ class StaticPagesServiceProvider extends ServiceProvider
// //
} }
/**
* Method for installing module into database
*/
protected function install()
{
$handler = '\\Modules\\StaticPages\\Handlers\\StaticPage';
$installedModules = Modules::getWithTranslations();
if (!isset($installedModules[$handler])) {
// insert module into database
Module::create([
'handler' => $handler,
'name' => 'staticpages::module.name',
'description' => 'staticpages::module.description'
]);
}
}
/** /**
* Register config. * Register config.
* *
@@ -82,14 +103,4 @@ class StaticPagesServiceProvider extends ServiceProvider
{ {
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'staticpages'); $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'staticpages');
} }
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
} }
@@ -0,0 +1,5 @@
<?php
return [
'name' => 'Static pages',
'description' => 'Static pages are intended for displaying static content on webpage.'
];