@@ -132,16 +132,17 @@ protected function getAllowedBundles($entity_type): array {
132132 * {@inheritdoc}
133133 */
134134 public function submitForm (array &$ form , FormStateInterface $ form_state ): void {
135+ $ cached_values = $ form_state ->getTemporaryValue (['wizard ' ]);
136+
135137 /** @var \Drupal\stanford_wordpress_migrate\WordPressMigrationInterface $migration */
136- $ migration = $ form_state ->getTemporaryValue ([
137- 'wizard ' ,
138- 'wordpress_migration ' ,
139- ]);
140- $ media = array_filter ($ form_state ->getValue ('mapping ' ), fn ($ mapping ) => $ mapping ['source ' ] && $ mapping ['destination ' ]);
141- $ chosen_sources = array_map (fn ($ a ) => $ a ['source ' ], $ media );
142- $ chosen_destinations = array_map (fn ($ a ) => $ a ['destination ' ], $ media );
138+ $ migration = $ cached_values ['wordpress_migration ' ];
139+ $ entity_type = $ cached_values ['entity_type ' ];
140+
141+ $ mappings = array_filter ($ form_state ->getValue ('mapping ' ), fn ($ mapping ) => $ mapping ['source ' ] && $ mapping ['destination ' ]);
142+ $ chosen_sources = array_map (fn ($ a ) => $ a ['source ' ], $ mappings );
143+ $ chosen_destinations = array_map (fn ($ a ) => $ a ['destination ' ], $ mappings );
143144
144- $ field_mapping = $ migration ->getConfigurationValue (' media ' , []);
145+ $ field_mapping = $ migration ->getConfigurationValue ($ entity_type , []);
145146
146147 // Remove any previously configured values that are no longer desired.
147148 foreach ($ field_mapping as $ source => $ destinations ) {
@@ -157,16 +158,16 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
157158 }
158159 }
159160 }
160- $ migration ->setConfigurationValue (' media ' , array_filter ($ field_mapping ));
161+ $ migration ->setConfigurationValue ($ entity_type , array_filter ($ field_mapping ));
161162
162- foreach ($ media as $ mapping ) {
163+ foreach ($ mappings as $ mapping ) {
163164 $ field_mapping = $ migration ->getConfigurationValue ([
164- ' media ' ,
165+ $ entity_type ,
165166 $ mapping ['source ' ],
166167 $ mapping ['destination ' ],
167168 ], []);
168169 $ migration ->setConfigurationValue ([
169- ' media ' ,
170+ $ entity_type ,
170171 $ mapping ['source ' ],
171172 $ mapping ['destination ' ],
172173 ], $ field_mapping );
0 commit comments