Skip to content

Commit

Permalink
Sort issues in Table of Content plugin by ORDERLABEL
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Jun 27, 2023
1 parent 93ba5f4 commit 7e40191
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Classes/Controller/TableOfContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ protected function resolveMenuEntry($entry)

/**
* Get translated type of entry.
*
*
* @param array $type
* @return string
*/
Expand All @@ -251,7 +251,7 @@ private function getTranslatedType($type) {

/**
* Set title from entry.
*
*
* @param array $entry
* @return string
*/
Expand All @@ -268,26 +268,29 @@ private function setTitle($entry) {
}

/**
* Sort menu by orderlabel - currently implemented for newspaper.
*
* Sort menu by orderlabel.
*
* @param array &$menu
* @return void
*/
private function sortMenu(&$menu) {
if ($menu[0]['type'] == $this->getTranslatedType("newspaper")) {
$this->sortMenuForNewspapers($menu);
$this->sortSubMenu($menu);
}
if ($menu[0]['type'] == $this->getTranslatedType("year")) {
$this->sortSubMenu($menu);
}
}

/**
* Sort menu years of the newspaper by orderlabel.
*
* Sort sub menu e.g years of the newspaper by orderlabel.
*
* @param array &$menu
* @return void
*/
private function sortMenuForNewspapers(&$menu) {
usort($menu[0]['_SUB_MENU'], function ($firstYear, $secondYear) {
return $firstYear['orderlabel'] <=> $secondYear['orderlabel'];
private function sortSubMenu(&$menu) {
usort($menu[0]['_SUB_MENU'], function ($firstElement, $secondElement) {
return $firstElement['orderlabel'] <=> $secondElement['orderlabel'];
});
}
}

0 comments on commit 7e40191

Please sign in to comment.