@@ -63,6 +63,7 @@ public static function get_site_types() {
6363 public function __invoke ( $ args , $ assoc_args ) {
6464
6565 $ site_types = self ::get_site_types ();
66+ $ assoc_args = $ this ->convert_old_args_to_new_args ( $ args , $ assoc_args );
6667
6768 if ( isset ( $ assoc_args ['type ' ] ) ) {
6869 $ type = $ assoc_args ['type ' ];
@@ -134,4 +135,68 @@ private function determine_type( $args ) {
134135
135136 return $ type ;
136137 }
138+
139+ /**
140+ * Convert EE v3 args to the newer syntax of arguments.
141+ *
142+ * @param array $args Commandline arguments passed.
143+ * @param array $assoc_args Commandline associative arguments passed.
144+ *
145+ * @return array Updated $assoc_args.
146+ */
147+ private function convert_old_args_to_new_args ( $ args , $ assoc_args ) {
148+
149+ $ ee3_compat_array_map_to_type = [
150+ 'wp ' => [ 'type ' => 'wp ' ],
151+ 'wpsubdom ' => [ 'type ' => 'wp ' , 'mu ' => 'subdom ' ],
152+ 'wpsubdir ' => [ 'type ' => 'wp ' , 'mu ' => 'subdir ' ],
153+ 'wpredis ' => [ 'type ' => 'wp ' , 'cache ' => true ],
154+ 'html ' => [ 'type ' => 'html ' ],
155+ 'php ' => [ 'type ' => 'php ' ],
156+ 'mysql ' => [ 'type ' => 'php ' , 'with-db ' => true ],
157+ 'le ' => [ 'ssl ' => 'le ' ],
158+ 'letsencrypt ' => [ 'ssl ' => 'le ' ],
159+ ];
160+
161+ foreach ( $ ee3_compat_array_map_to_type as $ from => $ to ) {
162+ if ( isset ( $ assoc_args [ $ from ] ) ) {
163+ $ assoc_args = array_merge ( $ assoc_args , $ to );
164+ unset( $ assoc_args [ $ from ] );
165+ }
166+ }
167+
168+ if ( ! empty ( $ assoc_args ['type ' ] ) && 'wp ' === $ assoc_args ['type ' ] ) {
169+
170+ // ee3 backward compatibility flags
171+ $ wp_compat_array_map = [
172+ 'user ' => 'admin-user ' ,
173+ 'pass ' => 'admin-pass ' ,
174+ 'email ' => 'admin-email ' ,
175+ ];
176+
177+ foreach ( $ wp_compat_array_map as $ from => $ to ) {
178+ if ( isset ( $ assoc_args [ $ from ] ) ) {
179+ $ assoc_args [ $ to ] = $ assoc_args [ $ from ];
180+ unset( $ assoc_args [ $ from ] );
181+ }
182+ }
183+ }
184+
185+ // backward compatibility error for deprecated flags.
186+ $ unsupported_create_old_args = array (
187+ 'w3tc ' ,
188+ 'wpsc ' ,
189+ 'wpfc ' ,
190+ 'pagespeed ' ,
191+ );
192+
193+ $ old_arg = array_intersect ( $ unsupported_create_old_args , array_keys ( $ assoc_args ) );
194+
195+ $ old_args = implode ( ' -- ' , $ old_arg );
196+ if ( isset ( $ args [1 ] ) && 'create ' === $ args [1 ] && ! empty ( $ old_arg ) ) {
197+ \EE ::error ( "Sorry, -- $ old_args flag/s is/are no longer supported in EE v4. \nPlease run `ee help " . implode ( ' ' , $ args ) . '`. ' );
198+ }
199+
200+ return $ assoc_args ;
201+ }
137202}
0 commit comments