Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Navigation.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
10 use \Magento\Framework\View\Element\Html\Links;
11 use \Magento\Customer\Block\Account\SortLinkInterface;
12 
19 class Navigation extends Links
20 {
25  public function getLinks()
26  {
27  $links = $this->_layout->getChildBlocks($this->getNameInLayout());
28  $sortableLink = [];
29  foreach ($links as $key => $link) {
30  if ($link instanceof SortLinkInterface) {
31  $sortableLink[] = $link;
32  unset($links[$key]);
33  }
34  }
35 
36  usort($sortableLink, [$this, "compare"]);
37  return array_merge($sortableLink, $links);
38  }
39 
48  private function compare(SortLinkInterface $firstLink, SortLinkInterface $secondLink): int
49  {
50  return $secondLink->getSortOrder() <=> $firstLink->getSortOrder();
51  }
52 }