Skip to content

Commit

Permalink
f2
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed May 17, 2023
1 parent 95bd1ae commit d48d650
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Classes/Controller/TableOfContentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected function resolveMenuEntry($entry)

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

/**
* Set title from entry.
*
*
* @param array $entry
* @return string
*/
Expand All @@ -270,19 +270,22 @@ private function setTitle($entry) {

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

/**
* Sort menu years of the newspaper by orderlabel.
*
*
* @param array &$menu
* @return void
*/
Expand All @@ -291,4 +294,16 @@ private function sortMenuForNewspapers(&$menu) {
return $firstYear['orderlabel'] <=> $secondYear['orderlabel'];
});
}

/**
* Sort menu years of the newspaper by orderlabel.
*
* @param array &$menu
* @return void
*/
private function sortMenuForYears(&$menu) {
usort($menu[0]['_SUB_MENU'], function ($firstIssue, $secondIssue) {
return $firstIssue['orderlabel'] <=> $secondIssue['orderlabel'];
});
}
}

0 comments on commit d48d650

Please sign in to comment.