Skip to content

Commit 346b02a

Browse files
author
vagrant
committed
Configurable stubs
1 parent 59760d9 commit 346b02a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Console/WidgetMakeCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,15 @@ protected function buildClass($name)
7272
*/
7373
protected function getStub()
7474
{
75-
if ($this->option('plain')) {
76-
return __DIR__.'/stubs/widget_plain.stub';
75+
$stubName = $this->option('plain') ? 'widget_plain' : 'widget';
76+
$stubPath = $this->laravel->make('config')->get('laravel-widgets.'.$stubName.'_stub');
77+
78+
// for BC
79+
if (is_null($stubPath)) {
80+
return __DIR__.'/stubs/'.$stubName.'.stub';
7781
}
7882

79-
return __DIR__.'/stubs/widget.stub';
83+
return $this->laravel->basePath().'/'.$stubPath;
8084
}
8185

8286
/**

src/config/config.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,16 @@
22

33
return [
44
//'default_namespace' => 'App\Widgets',
5+
56
'use_jquery_for_ajax_calls' => false,
7+
8+
/*
9+
* Relative path from the base directory to a regular widget stub.
10+
*/
11+
'widget_stub' => 'vendor/arrilot/laravel-widgets/src/Console/stubs/widget.stub',
12+
13+
/*
14+
* Relative path from the base directory to a plain widget stub.
15+
*/
16+
'widget_plain_stub' => 'vendor/arrilot/laravel-widgets/src/Console/stubs/widget_plain.stub',
617
];

0 commit comments

Comments
 (0)