Skip to content

Commit 499cafb

Browse files
committed
Refactor code and fixed static test failure
1 parent b67eb5f commit 499cafb

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

app/code/Magento/Backend/Block/Menu.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class Menu extends \Magento\Backend\Block\Template
2020
{
21-
const CACHE_TAGS = 'BACKEND_MAINMENU';
21+
public const CACHE_TAGS = 'BACKEND_MAINMENU';
2222

2323
/**
2424
* @var string
@@ -331,34 +331,27 @@ protected function _columnBrake($items, $limit)
331331
if ($total <= $limit) {
332332
return;
333333
}
334-
$result = [];
335334
$result[] = ['total' => $total, 'max' => ceil($total / ceil($total / $limit))];
336335
$count = 0;
337-
$itemCount = 0;
338-
$nextColBrake = false;
339336
foreach ($items as $item) {
340337
$place = $this->_countItems($item->getChildren()) + 1;
341-
$colbrake = false;
342-
$itemCount++;
343338
$count += $place;
344-
if ($nextColBrake) {
345-
$colbrake = true;
346-
$count = $place;
347-
} elseif ($place - $result[0]['max'] > $limit - $result[0]['max']) {
339+
if ($place - $result[0]['max'] > $limit - $result[0]['max']) {
348340
$colbrake = true;
349341
$count = 0;
350342
} elseif ($count - $result[0]['max'] > $limit - $result[0]['max']) {
351343
$colbrake = true;
352344
$count = $place;
345+
} else {
346+
$colbrake = false;
353347
}
354-
355-
$nextColBrake = false;
356-
if ($itemCount == 1 && $colbrake) {
357-
$nextColBrake = true;
358-
}
359-
360348
$result[] = ['place' => $place, 'colbrake' => $colbrake];
361349
}
350+
351+
if (isset($result[1]) && $result[1]['colbrake'] === true && isset($result[2])) {
352+
$result[2]['colbrake'] = true;
353+
}
354+
362355
return $result;
363356
}
364357

0 commit comments

Comments
 (0)