File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,9 +26,15 @@ protected function configure()
2626 ->setName ('database:connect ' )
2727 ->setDescription ($ this ->trans ('commands.database.connect.description ' ))
2828 ->addArgument (
29- 'database ' ,
29+ 'key ' ,
3030 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 ' ),
3238 'default '
3339 )
3440 ->setHelp ($ this ->trans ('commands.database.connect.help ' ))
@@ -40,8 +46,9 @@ protected function configure()
4046 */
4147 protected function execute (InputInterface $ input , OutputInterface $ output )
4248 {
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 );
4552
4653 $ connection = sprintf (
4754 '%s -A --database=%s --user=%s --password=%s --host=%s --port=%s ' ,
Original file line number Diff line number Diff line change 1111
1212trait ConnectTrait
1313{
14- protected $ supportedDrivers = ['mysql ' ,'pgsql ' ];
14+ protected $ supportedDrivers = ['mysql ' , 'pgsql ' ];
1515
16- public function resolveConnection ($ database = 'default ' )
16+ public function resolveConnection ($ key = ' default ' , $ target = 'default ' )
1717 {
18- $ connectionInfo = Database::getConnectionInfo ();
19-
20- if (!$ connectionInfo || !isset ($ connectionInfo [$ database ])) {
18+ $ connectionInfo = Database::getConnectionInfo ($ key );
19+ if (!$ connectionInfo || !isset ($ connectionInfo [$ target ])) {
2120 $ this ->getIo ()->error (
2221 sprintf (
2322 $ this ->trans ('commands.database.connect.messages.database-not-found ' ),
24- $ database
23+ $ key ,
24+ $ target
2525 )
2626 );
2727
2828 return null ;
2929 }
3030
31- $ databaseConnection = $ connectionInfo [$ database ];
31+ $ databaseConnection = $ connectionInfo [$ target ];
3232 if (!in_array ($ databaseConnection ['driver ' ], $ this ->supportedDrivers )) {
3333 $ this ->getIo ()->error (
3434 sprintf (
You can’t perform that action at this time.
0 commit comments