← All changes
|
modules/variables/import-export-customization/runners/import.php
+1
-26
4.0.9
→
4.0.0-beta1
View file →
| @@ -57,9 +57,9 @@ | ||
| 57 | 57 | |
| 58 | 58 | return $variables_data; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $existing_collection = $this->get_existing_collection( $repository, $imported_data ); | |
| 61 | + $existing_collection = $repository->load(); | |
| 62 | 62 | $imported_collection = Variables_Collection::hydrate( $variables_data ); |
| 63 | 63 | |
| 64 | 64 | $merged_collection = $this->merge_collections( $existing_collection, $imported_collection ); |
| 65 | 65 | $this->save_collection( $repository, $merged_collection ); |
| @@ -64,33 +64,8 @@ | ||
| 64 | 64 | $merged_collection = $this->merge_collections( $existing_collection, $imported_collection ); |
| 65 | 65 | $this->save_collection( $repository, $merged_collection ); |
| 66 | 66 | |
| 67 | 67 | return $variables_data; |
| 68 | - } | |
| 69 | - | |
| 70 | - private function get_existing_collection( Variables_Repository $repository, array $imported_data ): Variables_Collection { | |
| 71 | - $existing = $repository->load(); | |
| 72 | - | |
| 73 | - if ( count( $existing->all() ) > 0 ) { | |
| 74 | - return $existing; | |
| 75 | - } | |
| 76 | - | |
| 77 | - $was_new_kit_created = ! empty( $imported_data['site-settings']['imported_kit_id'] ); | |
| 78 | - | |
| 79 | - if ( ! $was_new_kit_created ) { | |
| 80 | - return $existing; | |
| 81 | - } | |
| 82 | - | |
| 83 | - $previous_kit_id = Plugin::$instance->kits_manager->get_previous_id(); | |
| 84 | - | |
| 85 | - if ( ! $previous_kit_id ) { | |
| 86 | - return $existing; | |
| 87 | - } | |
| 88 | - | |
| 89 | - $previous_kit = Plugin::$instance->kits_manager->get_kit( $previous_kit_id ); | |
| 90 | - $previous_repository = new Variables_Repository( $previous_kit ); | |
| 91 | - | |
| 92 | - return $previous_repository->load(); | |
| 93 | 68 | } |
| 94 | 69 | |
| 95 | 70 | private function merge_collections( |
| 96 | 71 | Variables_Collection $existing, |