diff --git a/config/modules.php b/config/modules.php index 192953c4..ae9e1923 100644 --- a/config/modules.php +++ b/config/modules.php @@ -2,70 +2,81 @@ return [ - /* - |-------------------------------------------------------------------------- - | Path to Modules - |-------------------------------------------------------------------------- - | - | Define the path where you'd like to store your modules. Note that if you - | choose a path that's outside of your public directory, you will need to - | copy your module assets (CSS, images, etc.) to your public directory. - | - */ + /* + |-------------------------------------------------------------------------- + | Path to Modules + |-------------------------------------------------------------------------- + | + | Define the path where you'd like to store your modules. Note that if you + | choose a path that's outside of your public directory, you will need to + | copy your module assets (CSS, images, etc.) to your public directory. + | + */ - 'path' => app_path('Modules'), + 'path' => app_path('Modules'), - /* - |-------------------------------------------------------------------------- - | Modules Default State - |-------------------------------------------------------------------------- - | - | When a previously unknown module is added, if it doesn't have an 'enabled' - | state set then this is the value which it will default to. If this is - | not provided then the module will default to being 'enabled'. - | - */ + /* + |-------------------------------------------------------------------------- + | Modules Default State + |-------------------------------------------------------------------------- + | + | When a previously unknown module is added, if it doesn't have an 'enabled' + | state set then this is the value which it will default to. If this is + | not provided then the module will default to being 'enabled'. + | + */ 'enabled' => true, - /* - |-------------------------------------------------------------------------- - | Modules Base Namespace - |-------------------------------------------------------------------------- - | - | Define the base namespace for your modules. Be sure to update this value - | if you move your modules directory to a new path. This is primarily used - | by the module:make Artisan command. - | - */ + /* + |-------------------------------------------------------------------------- + | Modules Base Namespace + |-------------------------------------------------------------------------- + | + | Define the base namespace for your modules. Be sure to update this value + | if you move your modules directory to a new path. This is primarily used + | by the module:make Artisan command. + | + */ - 'namespace' => 'App\Modules\\', + 'namespace' => 'App\Modules\\', - /* - |-------------------------------------------------------------------------- - | Default Module Driver - |-------------------------------------------------------------------------- - | - | This option controls the module storage driver that will be utilized. - | This driver manages the retrieval and management of module properties. - | Setting this to custom allows you to specify your own driver instance. - | - | Supported: "local", "custom" - | - */ + /* + |-------------------------------------------------------------------------- + | Default Module Driver + |-------------------------------------------------------------------------- + | + | This option controls the module storage driver that will be utilized. + | This driver manages the retrieval and management of module properties. + | Setting this to custom allows you to specify your own driver instance. + | + | Supported: "local", "custom" + | + */ - 'driver' => 'local', + 'driver' => 'local', - /* - |-------------------------------------------------------------------------- - | Custom Module Driver - |-------------------------------------------------------------------------- - | - | This option allows one to define a custom module driver implementation. - | This is useful in cases where you may need to support and store module - | properties somewhere not supported by default. - | - */ + /* + |-------------------------------------------------------------------------- + | Custom Module Driver + |-------------------------------------------------------------------------- + | + | This option allows one to define a custom module driver implementation. + | This is useful in cases where you may need to support and store module + | properties somewhere not supported by default. + | + */ - 'custom_driver' => 'App\Repositories\Modules\CustomRepository', + 'custom_driver' => 'App\Repositories\Modules\CustomRepository', + + /* + |-------------------------------------------------------------------------- + | Custom Stubs + |-------------------------------------------------------------------------- + | + | This option allows to define a custom stubs. + | php artisan vendor:publish --tag=stubs + | + */ + //'custom_stubs' => base_path('resources/stubs/'), ]; diff --git a/src/Console/Generators/MakeCommand.php b/src/Console/Generators/MakeCommand.php index 7d8ded24..9a3a6c74 100644 --- a/src/Console/Generators/MakeCommand.php +++ b/src/Console/Generators/MakeCommand.php @@ -308,8 +308,11 @@ protected function getBaseNamespace() */ protected function getStubContent($stubName) { - $stubPath = __DIR__.'/../../../resources/stubs/'; - + if(!empty(config('modules.custom_stubs'))){ + $stubPath = config('modules.custom_stubs'); + }else{ + $stubPath = __DIR__.'/../../../resources/stubs/'; + } return $this->formatContent($this->files->get($stubPath.$stubName)); } diff --git a/src/Console/Generators/MakeModuleCommand.php b/src/Console/Generators/MakeModuleCommand.php index bbdbe51f..c23ec41e 100644 --- a/src/Console/Generators/MakeModuleCommand.php +++ b/src/Console/Generators/MakeModuleCommand.php @@ -316,8 +316,12 @@ protected function formatContent($content) */ protected function displayHeader($file = '', $level = 'info') { - $stub = $this->files->get(__DIR__.'/../../../resources/stubs/console/'.$file.'.stub'); - + if(!empty(config('modules.custom_stubs'))){ + $stub = $this->files->get(config('modules.custom_stubs').'/console/'.$file.'.stub'); + }else{ + $stub = $this->files->get(__DIR__.'/../../../resources/stubs/console/'.$file.'.stub'); + } + return $this->$level($stub); } } diff --git a/src/ModulesServiceProvider.php b/src/ModulesServiceProvider.php index d5475e70..b0118d7d 100644 --- a/src/ModulesServiceProvider.php +++ b/src/ModulesServiceProvider.php @@ -20,6 +20,12 @@ public function boot() __DIR__.'/../config/modules.php' => config_path('modules.php'), ], 'config'); + if(config('modules.custom_stubs')){ + $this->publishes([ + __DIR__.'/../resources/stubs/' => config('modules.custom_stubs'), + ], 'stubs'); + } + $modules = $this->app['modules']; $modules->register();