FIX: lots of bugfixes, sorry for ugly commit

This commit is contained in:
Michal Kváček
2017-02-09 23:10:11 +01:00
parent 99ed8806da
commit b7d4ab9515
47 changed files with 180 additions and 199 deletions
+11 -9
View File
@@ -3,18 +3,19 @@ namespace App\Providers;
use Illuminate\Support\ServiceProvider;
abstract class ModuleServiceProvider extends ServiceProvider {
abstract class ModuleServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
protected $alias = false;
protected $path = false;
abstract protected function setModuleAlias();
abstract protected function setModulePath();
/**
@@ -26,7 +27,7 @@ abstract class ModuleServiceProvider extends ServiceProvider {
{
$this->setModuleAlias();
$this->setModulePath();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
@@ -39,7 +40,7 @@ abstract class ModuleServiceProvider extends ServiceProvider {
*/
protected function registerConfig()
{
$this->publishes([$this->path . '/../Config/config.php' => config_path($this->alias.'.php')]);
$this->publishes([$this->path . '/../Config/config.php' => config_path($this->alias . '.php')]);
$this->mergeConfigFrom($this->path . '/../Config/config.php', $this->alias);
}
@@ -54,14 +55,16 @@ abstract class ModuleServiceProvider extends ServiceProvider {
*/
protected function registerViews()
{
$viewPath = base_path('resources/views/modules/'.$this->alias);
$viewPath = base_path('resources/views/modules/' . $this->alias);
$sourcePath = $this->path . '/../Resources/views';
$this->publishes([$sourcePath => $viewPath], 'module-views');
$this->loadViewsFrom(array_merge(array_map(function ($path) {
return $path . '/modules/'.$this->alias;
return $path . '/modules/' . $this->alias;
}, \Config::get('view.paths')), [$sourcePath]), $this->alias);
if (is_dir($sourcePath)) {
$this->publishes([$sourcePath => $viewPath], 'module-views');
}
}
/**
@@ -73,5 +76,4 @@ abstract class ModuleServiceProvider extends ServiceProvider {
{
$this->loadTranslationsFrom($this->path . '/../Resources/lang', $this->alias);
}
}