File tree 2 files changed +18
-11
lines changed
2 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,15 @@ protected function configure()
26
26
->setName ('database:connect ' )
27
27
->setDescription ($ this ->trans ('commands.database.connect.description ' ))
28
28
->addArgument (
29
- 'database ' ,
29
+ 'key ' ,
30
30
InputArgument::OPTIONAL ,
31
- $ this ->trans ('commands.database.connect.arguments.database ' ),
31
+ $ this ->trans ('commands.database.connect.arguments.key ' ),
32
+ 'default '
33
+ )
34
+ ->addArgument (
35
+ 'target ' ,
36
+ InputArgument::OPTIONAL ,
37
+ $ this ->trans ('commands.database.connect.arguments.target ' ),
32
38
'default '
33
39
)
34
40
->setHelp ($ this ->trans ('commands.database.connect.help ' ))
@@ -40,8 +46,9 @@ protected function configure()
40
46
*/
41
47
protected function execute (InputInterface $ input , OutputInterface $ output )
42
48
{
43
- $ database = $ input ->getArgument ('database ' );
44
- $ databaseConnection = $ this ->resolveConnection ($ database );
49
+ $ key = $ input ->getArgument ('key ' );
50
+ $ target = $ input ->getArgument ('target ' );
51
+ $ databaseConnection = $ this ->resolveConnection ($ key , $ target );
45
52
46
53
$ connection = sprintf (
47
54
'%s -A --database=%s --user=%s --password=%s --host=%s --port=%s ' ,
Original file line number Diff line number Diff line change 11
11
12
12
trait ConnectTrait
13
13
{
14
- protected $ supportedDrivers = ['mysql ' ,'pgsql ' ];
14
+ protected $ supportedDrivers = ['mysql ' , 'pgsql ' ];
15
15
16
- public function resolveConnection ($ database = 'default ' )
16
+ public function resolveConnection ($ key = ' default ' , $ target = 'default ' )
17
17
{
18
- $ connectionInfo = Database::getConnectionInfo ();
19
-
20
- if (!$ connectionInfo || !isset ($ connectionInfo [$ database ])) {
18
+ $ connectionInfo = Database::getConnectionInfo ($ key );
19
+ if (!$ connectionInfo || !isset ($ connectionInfo [$ target ])) {
21
20
$ this ->getIo ()->error (
22
21
sprintf (
23
22
$ this ->trans ('commands.database.connect.messages.database-not-found ' ),
24
- $ database
23
+ $ key ,
24
+ $ target
25
25
)
26
26
);
27
27
28
28
return null ;
29
29
}
30
30
31
- $ databaseConnection = $ connectionInfo [$ database ];
31
+ $ databaseConnection = $ connectionInfo [$ target ];
32
32
if (!in_array ($ databaseConnection ['driver ' ], $ this ->supportedDrivers )) {
33
33
$ this ->getIo ()->error (
34
34
sprintf (
You can’t perform that action at this time.
0 commit comments