Completed
Push — master ( 778190...a7cb3d )
by Tim
01:31
created
src/Listeners/SortCategoryListener.php 1 patch
Spacing   +6 added lines, -9 removed lines patch added patch discarded remove patch
@@ -164,11 +164,9 @@  discard block
 block discarded – undo
164 164
 
165 165
             // sort the main rows by the path, store_view_code and position
166 166
             // ATTENTION: we use uasort, because we NEED to preserve the keys
167
-            uasort($this->mainRows, function ($a, $b) {
167
+            uasort($this->mainRows, function($a, $b) {
168 168
                 return
169
-                    strcmp($a[ColumnKeys::PATH], $b[ColumnKeys::PATH]) ?:
170
-                    strcmp($a[ColumnKeys::STORE_VIEW_CODE], $b[ColumnKeys::STORE_VIEW_CODE]) ?:
171
-                    strcmp($a[ColumnKeys::POSITION], $b[ColumnKeys::POSITION]);
169
+                    strcmp($a[ColumnKeys::PATH], $b[ColumnKeys::PATH]) ?: strcmp($a[ColumnKeys::STORE_VIEW_CODE], $b[ColumnKeys::STORE_VIEW_CODE]) ?: strcmp($a[ColumnKeys::POSITION], $b[ColumnKeys::POSITION]);
172 170
             });
173 171
 
174 172
             // update the position of the categories and the categories on the same level
@@ -181,10 +179,9 @@  discard block
 block discarded – undo
181 179
             $this->artefacts = array_merge(array_values($this->artefacts), $this->storeViewRows);
182 180
 
183 181
             // sort the artefacts again, because we want to export them in the expected order
184
-            usort($this->artefacts, function ($a, $b) {
182
+            usort($this->artefacts, function($a, $b) {
185 183
                 return
186
-                    strcmp($a[ColumnKeys::PATH], $b[ColumnKeys::PATH]) ?:
187
-                    strcmp($a[ColumnKeys::STORE_VIEW_CODE], $b[ColumnKeys::STORE_VIEW_CODE]);
184
+                    strcmp($a[ColumnKeys::PATH], $b[ColumnKeys::PATH]) ?: strcmp($a[ColumnKeys::STORE_VIEW_CODE], $b[ColumnKeys::STORE_VIEW_CODE]);
188 185
             });
189 186
 
190 187
             // replace the artefacts to be exported later
@@ -284,7 +281,7 @@  discard block
 block discarded – undo
284 281
         }
285 282
 
286 283
         // sor the categories by their position and KEEP the keys
287
-        uasort($categoriesOnSameLevel, function ($a, $b) {
284
+        uasort($categoriesOnSameLevel, function($a, $b) {
288 285
             // return 0 when the position is equal (should never happen)
289 286
             if ($a[MemberNames::POSITION] == $b[MemberNames::POSITION]) {
290 287
                 return 0;
@@ -432,7 +429,7 @@  discard block
 block discarded – undo
432 429
         // iterate over the IDs
433 430
         foreach ($ids as $id) {
434 431
             // load the category with the actual ID
435
-            $existingCategories = array_filter($this->existingCategories, function ($existingCategory) use ($id) {
432
+            $existingCategories = array_filter($this->existingCategories, function($existingCategory) use ($id) {
436 433
                 return (int) $existingCategory[MemberNames::ENTITY_ID] === (int) $id;
437 434
             });
438 435
 
Please login to merge, or discard this patch.