@@ -52,14 +52,16 @@ public function execute() {
5252 $ this ->importOptions = $ this ->extractOptions ();
5353
5454 try {
55- $ importMode = $ this ->getImportMode ();
56- $ entityIdListBuilder = $ this ->newEntityIdListBuilder ( $ importMode );
55+ foreach ( $ this ->importOptions as $ importMode => $ input ) {
56+ $ this ->output ( " Importing $ importMode\n" );
5757
58- $ input = $ this ->getInputForMode ( $ importMode );
59- $ ids = $ entityIdListBuilder ->getEntityIds ( $ input );
58+ $ entityIdListBuilder = $ this ->newEntityIdListBuilder ( $ importMode );
6059
61- $ entityImporter = $ this ->newEntityImporter ();
62- $ entityImporter ->importEntities ( $ ids );
60+ $ ids = $ entityIdListBuilder ->getEntityIds ( $ input );
61+
62+ $ entityImporter = $ this ->newEntityImporter ();
63+ $ entityImporter ->importEntities ( $ ids );
64+ }
6365 }
6466 catch ( Exception $ ex ) {
6567 $ this ->error ( $ ex ->getMessage () );
@@ -93,7 +95,9 @@ private function extractOptions() {
9395 $ options = [];
9496
9597 foreach ( $ this ->getValidOptions () as $ optionName ) {
96- $ options [$ optionName ] = $ this ->getOption ( $ optionName );
98+ if ( $ this ->hasOption ( $ optionName ) ) {
99+ $ options [$ optionName ] = $ this ->getOptionValue ( $ optionName );
100+ }
97101 }
98102
99103 if ( empty ( $ options ) ) {
@@ -104,28 +108,14 @@ private function extractOptions() {
104108 }
105109
106110 /**
107- * @return string
108- * @throws RuntimeException
109- */
110- private function getImportMode () {
111- foreach ( $ this ->getValidOptions () as $ option ) {
112- if ( $ this ->importOptions ->hasOption ( $ option ) ) {
113- return $ option ;
114- }
115- }
116-
117- throw new RuntimeException ( 'No valid import option was provided ' );
118- }
119-
120- /**
121- * @param string $mode
111+ * @param string $optionName
122112 * @return mixed
123113 */
124- private function getInputForMode ( $ mode ) {
125- if ( $ mode === 'all-properties ' ) {
114+ private function getOptionValue ( $ optionName ) {
115+ if ( $ optionName === 'all-properties ' ) {
126116 return 'all-properties ' ;
127117 } else {
128- return $ this ->importOptions -> getOption ( $ mode );
118+ return $ this ->getOption ( $ optionName );
129119 }
130120 }
131121
0 commit comments