@@ -59,15 +59,7 @@ protected function markSnapshotApplied($path, Arguments $args, ConsoleIo $io)
5959 $ newArgs [] = $ version ;
6060 $ newArgs [] = '-o ' ;
6161
62- if ($ args ->getOption ('connection ' )) {
63- $ newArgs [] = '-c ' ;
64- $ newArgs [] = $ args ->getOption ('connection ' );
65- }
66-
67- if ($ args ->getOption ('plugin ' )) {
68- $ newArgs [] = '-p ' ;
69- $ newArgs [] = $ args ->getOption ('plugin ' );
70- }
62+ $ newArgs = array_merge ($ newArgs , $ this ->parseOptions ($ args ));
7163
7264 $ io ->out ('Marking the migration ' . $ fileName . ' as migrated... ' );
7365 $ this ->executeCommand (MigrationsMarkMigratedCommand::class, $ newArgs , $ io );
@@ -83,8 +75,21 @@ protected function markSnapshotApplied($path, Arguments $args, ConsoleIo $io)
8375 */
8476 protected function refreshDump (Arguments $ args , ConsoleIo $ io )
8577 {
86- $ newArgs = [];
78+ $ newArgs = $ this ->parseOptions ($ args );
79+
80+ $ io ->out ('Creating a dump of the new database state... ' );
81+ $ this ->executeCommand (MigrationsDumpCommand::class, $ newArgs , $ io );
82+ }
8783
84+ /**
85+ * Will parse 'connection', 'plugin' and 'source' options into a new Array
86+ *
87+ * @param \Cake\Console\Arguments $args The command arguments.
88+ * @return array Array containing the short for the option followed by its value
89+ */
90+ protected function parseOptions (Arguments $ args ): array
91+ {
92+ $ newArgs = [];
8893 if ($ args ->getOption ('connection ' )) {
8994 $ newArgs [] = '-c ' ;
9095 $ newArgs [] = $ args ->getOption ('connection ' );
@@ -95,7 +100,11 @@ protected function refreshDump(Arguments $args, ConsoleIo $io)
95100 $ newArgs [] = $ args ->getOption ('plugin ' );
96101 }
97102
98- $ io ->out ('Creating a dump of the new database state... ' );
99- $ this ->executeCommand (MigrationsDumpCommand::class, $ newArgs , $ io );
103+ if ($ args ->getOption ('source ' )) {
104+ $ newArgs [] = '-s ' ;
105+ $ newArgs [] = $ args ->getOption ('source ' );
106+ }
107+
108+ return $ newArgs ;
100109 }
101110}
0 commit comments