← All changes
|
modules/variables/services/variables-service.php
+2
-9
4.1.3
→
3.35.0-dev4
View file →
| @@ -93,9 +93,8 @@ | ||
| 93 | 93 | $data['order'] = $collection->get_next_order(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $variable = Variable::from_array( $data ); |
| 97 | - $variable->validate(); | |
| 98 | 97 | |
| 99 | 98 | $collection->add_variable( $variable ); |
| 100 | 99 | |
| 101 | 100 | $watermark = $this->repo->save( $collection ); |
| @@ -121,9 +120,8 @@ | ||
| 121 | 120 | $collection->assert_label_is_unique( $data['label'], $id ); |
| 122 | 121 | } |
| 123 | 122 | |
| 124 | 123 | $variable->apply_changes( $data ); |
| 125 | - $variable->validate(); | |
| 126 | 124 | |
| 127 | 125 | $watermark = $this->repo->save( $collection ); |
| 128 | 126 | |
| 129 | 127 | if ( false === $watermark ) { |
| @@ -166,20 +164,15 @@ | ||
| 166 | 164 | public function restore( string $id, $overrides = [] ) { |
| 167 | 165 | $collection = $this->repo->load(); |
| 168 | 166 | $variable = $collection->find_or_fail( $id ); |
| 169 | 167 | |
| 170 | - $label = $variable->label(); | |
| 168 | + $collection->assert_limit_not_reached(); | |
| 171 | 169 | |
| 172 | 170 | if ( isset( $overrides['label'] ) ) { |
| 173 | - $label = $overrides['label']; | |
| 171 | + $collection->assert_label_is_unique( $overrides['label'], $variable->id() ); | |
| 174 | 172 | } |
| 175 | 173 | |
| 176 | - $collection->assert_limit_not_reached(); | |
| 177 | - | |
| 178 | - $collection->assert_label_is_unique( $label, $variable->id() ); | |
| 179 | - | |
| 180 | 174 | $variable->apply_changes( $overrides ); |
| 181 | - $variable->validate(); | |
| 182 | 175 | |
| 183 | 176 | $variable->restore(); |
| 184 | 177 | |
| 185 | 178 | $watermark = $this->repo->save( $collection ); |