File tree Expand file tree Collapse file tree 4 files changed +49
-42
lines changed Expand file tree Collapse file tree 4 files changed +49
-42
lines changed Original file line number Diff line number Diff line change 22
33namespace Webfactor \Laravel \Generators \Commands ;
44
5- use Illuminate \ Console \ Command ;
5+ use Webfactor \ Laravel \ Generators \ Contracts \ CommandAbstract ;
66use Webfactor \Laravel \Generators \Contracts \ServiceInterface ;
77use Webfactor \Laravel \Generators \Schemas \Schema ;
88use Webfactor \Laravel \Generators \Services \AddToGitService ;
99use Webfactor \Laravel \Generators \Services \OpenIdeService ;
1010
11- class MakeEntity extends Command
11+ class MakeEntity extends CommandAbstract
1212{
1313 /**
1414 * The name and signature of the console command.
@@ -24,35 +24,13 @@ class MakeEntity extends Command
2424 */
2525 protected $ description = 'Make Entity ' ;
2626
27- /**
28- * Paths to files which should automatically be opened in IDE if the
29- * option --ide is set (and IDE capable).
30- *
31- * @var array
32- */
33- public $ filesToBeOpened = [];
34-
35- /**
36- * The name of the entity being created.
37- *
38- * @var string
39- */
40- public $ entity ;
41-
4227 /**
4328 * The Schema object.
4429 *
4530 * @var Schema
4631 */
4732 public $ schema ;
4833
49- /**
50- * The naming schema object.
51- *
52- * @var array
53- */
54- public $ naming = [];
55-
5634 /**
5735 * Execute the console command.
5836 *
@@ -124,17 +102,4 @@ private function executeService(ServiceInterface $service)
124102 {
125103 $ service ->call ();
126104 }
127-
128- /**
129- * Adds file to $filesToBeOpened stack.
130- *
131- * @param $file
132- * @return void
133- */
134- public function addFile (?\SplFileInfo $ file ): void
135- {
136- if ($ file ) {
137- array_push ($ this ->filesToBeOpened , $ file );
138- }
139- }
140105}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Webfactor \Laravel \Generators \Contracts ;
4+
5+ use Illuminate \Console \Command ;
6+
7+ abstract class CommandAbstract extends Command
8+ {
9+ /**
10+ * Paths to files which should automatically be opened in IDE if the
11+ * option --ide is set (and IDE capable).
12+ *
13+ * @var array
14+ */
15+ public $ filesToBeOpened = [];
16+
17+ /**
18+ * The name of the entity being created.
19+ *
20+ * @var string
21+ */
22+ public $ entity ;
23+
24+ /**
25+ * The naming classes.
26+ *
27+ * @var array
28+ */
29+ public $ naming = [];
30+
31+ /**
32+ * Adds file to $filesToBeOpened stack.
33+ *
34+ * @param $file
35+ * @return void
36+ */
37+ public function addFile (?\SplFileInfo $ file ): void
38+ {
39+ if ($ file ) {
40+ array_push ($ this ->filesToBeOpened , $ file );
41+ }
42+ }
43+ }
Original file line number Diff line number Diff line change 33namespace Webfactor \Laravel \Generators \Contracts ;
44
55use Illuminate \Filesystem \Filesystem ;
6- use Webfactor \Laravel \Generators \Commands \MakeEntity ;
76
87abstract class ServiceAbstract
98{
@@ -15,12 +14,14 @@ abstract class ServiceAbstract
1514
1615 protected $ filesystem ;
1716
18- public function __construct (MakeEntity $ command )
17+ public function __construct (CommandAbstract $ command, ? NamingAbstract $ naming = null )
1918 {
2019 $ this ->command = $ command ;
2120 $ this ->filesystem = new Filesystem ();
2221
23- if ($ this ->key ) {
22+ $ this ->naming = $ naming ;
23+
24+ if (is_null ($ naming ) && $ this ->key ) {
2425 $ this ->naming = $ this ->command ->naming [$ this ->key ];
2526 }
2627 }
Original file line number Diff line number Diff line change 22
33namespace Webfactor \Laravel \Generators \Services ;
44
5- use Illuminate \Filesystem \Filesystem ;
6- use Webfactor \Laravel \Generators \Commands \MakeEntity ;
75use Webfactor \Laravel \Generators \Contracts \ServiceAbstract ;
86use Webfactor \Laravel \Generators \Contracts \ServiceInterface ;
97
You can’t perform that action at this time.
0 commit comments