22
33namespace Farzai \Viola \Commands ;
44
5- use Farzai \Viola \Contracts \DatabaseConnectionRepositoryInterface ;
6- use Farzai \Viola \Contracts \StorageRepositoryInterface ;
75use Farzai \Viola \Database \ConnectorFactory ;
8- use Farzai \Viola \Storage \CacheFilesystemStorage ;
9- use Farzai \Viola \Storage \DatabaseConnectionRepository ;
106
11- class Config extends Command
7+ class Config extends AbstractContextCommand
128{
13- protected static $ defaultName = 'config ' ;
14-
15- private StorageRepositoryInterface $ storage ;
16-
17- private DatabaseConnectionRepositoryInterface $ databaseConfig ;
18-
199 protected function configure ()
2010 {
2111 $ this ->setDescription ('Config API key and database connection. ' );
22-
23- $ this ->storage = new CacheFilesystemStorage ();
24- $ this ->databaseConfig = new DatabaseConnectionRepository (new CacheFilesystemStorage ());
2512 }
2613
2714 protected function handle (): int
@@ -40,7 +27,7 @@ protected function handle(): int
4027 } else {
4128 $ this ->error ('API key is required. ' );
4229
43- return Command ::FAILURE ;
30+ return static ::FAILURE ;
4431 }
4532
4633 $ this ->info ('Setting up database connection... ' );
@@ -50,7 +37,7 @@ protected function handle(): int
5037 if (! $ connectionName || empty ($ connectionName )) {
5138 $ this ->error ('Database connection name is required. ' );
5239
53- return Command ::FAILURE ;
40+ return static ::FAILURE ;
5441 }
5542
5643 $ connections = $ this ->databaseConfig ->all ();
@@ -62,7 +49,7 @@ protected function handle(): int
6249 if (! $ this ->confirm ("Connection {$ connectionName } already exists. Do you want to continue edit it? " )) {
6350 $ this ->info ('Cancelled. ' );
6451
65- return Command ::SUCCESS ;
52+ return static ::SUCCESS ;
6653 }
6754 }
6855 }
@@ -82,7 +69,7 @@ protected function handle(): int
8269 if (! isset ($ stubConfig ['drivers ' ][$ driver ])) {
8370 $ this ->error ('Only support ' .implode (', ' , array_keys ($ stubConfig ['drivers ' ])).' driver. ' );
8471
85- return Command ::FAILURE ;
72+ return static ::FAILURE ;
8673 }
8774
8875 $ stubConfig = $ stubConfig ['drivers ' ][$ driver ];
@@ -124,7 +111,7 @@ protected function handle(): int
124111
125112 $ this ->info ('Connection successful!, Platform: ' .$ platform );
126113
127- return Command ::SUCCESS ;
114+ return static ::SUCCESS ;
128115 } catch (\Exception $ e ) {
129116 $ this ->error ('Connection failed!, ' .$ e ->getMessage ());
130117 }
@@ -140,6 +127,6 @@ protected function handle(): int
140127 }
141128 }
142129
143- return Command ::SUCCESS ;
130+ return static ::SUCCESS ;
144131 }
145132}
0 commit comments