FIX: lots of bugfixes, sorry for ugly commit
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user