Skip to content

Commit

Permalink
Merge pull request #201 from Venko007/master
Browse files Browse the repository at this point in the history
custom stubs
  • Loading branch information
kaidesu authored Jun 27, 2016
2 parents 510131f + 1a82a11 commit b7ed3a9
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 60 deletions.
123 changes: 67 additions & 56 deletions config/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/'),
];
7 changes: 5 additions & 2 deletions src/Console/Generators/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
8 changes: 6 additions & 2 deletions src/Console/Generators/MakeModuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 6 additions & 0 deletions src/ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit b7ed3a9

Please sign in to comment.