File tree Expand file tree Collapse file tree 3 files changed +10
-16
lines changed Expand file tree Collapse file tree 3 files changed +10
-16
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
namespace Backpack \Generators \Console \Commands \Traits ;
4
+ use Illuminate \Support \Str ;
4
5
5
6
trait PublishableStubTrait
6
7
{
7
8
/**
8
- * Check if the stub exists in the project's stubs folder.
9
- * If it does, return the path to it.
10
- * If it doesn't, return the path to the stub in the package.
11
- *
12
- * @param string $path
13
- * @return string
9
+ * Return the path to the stub
14
10
*/
15
11
public function getStubPath (string $ path ): string
16
12
{
17
- if (file_exists (base_path ("stubs/backpack/generators/ {$ path }.stub " ))) {
18
- return base_path ("stubs/backpack/generators/ {$ path }.stub " );
13
+ $ path = Str::finish ($ path , '.stub ' );
14
+
15
+ if (file_exists (base_path ("stubs/backpack/generators/ {$ path }" ))) {
16
+ return base_path ("stubs/backpack/generators/ {$ path }" );
19
17
}
20
18
21
- return __DIR__ ."/../../stubs/ {$ path }.stub " ;
19
+ return __DIR__ ."/../../stubs/ {$ path }" ;
22
20
}
23
21
}
Original file line number Diff line number Diff line change 9
9
abstract class PublishOrCreateViewBackpackCommand extends GeneratorCommand
10
10
{
11
11
use \Backpack \CRUD \app \Console \Commands \Traits \PrettyCommandOutput;
12
+ use \Backpack \Generators \Console \Commands \Traits \PublishableStubTrait;
12
13
13
14
/**
14
15
* The source file to copy from.
@@ -41,12 +42,7 @@ abstract class PublishOrCreateViewBackpackCommand extends GeneratorCommand
41
42
*/
42
43
protected function getStub ()
43
44
{
44
- // check if base_path('stubs/backpack/generators/$FILE') exists, and use that
45
- if (file_exists (base_path ('stubs/backpack/generators/generators/ ' .$ this ->stub ))) {
46
- return base_path ('stubs/backpack/generators/generators/ ' .$ this ->stub );
47
- }
48
-
49
- return __DIR__ .'/../../stubs/ ' .$ this ->stub ;
45
+ return $ this ->getStubPath ($ this ->stub );
50
46
}
51
47
52
48
/**
Original file line number Diff line number Diff line change @@ -55,6 +55,6 @@ public function boot(): void
55
55
56
56
$ this ->publishes ([
57
57
__DIR__ .'/Console/stubs ' => base_path ('stubs/backpack/generators ' ),
58
- ], 'stubs ' );
58
+ ], 'backpack-generators- stubs ' );
59
59
}
60
60
}
You can’t perform that action at this time.
0 commit comments