MDL-78656 output: display menu item titles in primary navigation.

Since custom menu items were merged into the primary navigation/more
menu as part of 56c34d71 and related work, the "title" attribute of
each custom menu item was lost.
This commit is contained in:
Paul Holden
2023-08-22 17:29:59 +01:00
parent e998f14061
commit c19d9693e9
2 changed files with 29 additions and 7 deletions
+13 -4
View File
@@ -582,11 +582,20 @@ class navigation_node implements renderable {
/**
* Sets the title for this node and forces Moodle to utilise it.
* @param string $title
*
* Note that this method is named identically to the public "title" property of the class, which unfortunately confuses
* our Mustache renderer, because it will see the method and try and call it without any arguments (hence must be nullable)
* before trying to access the public property
*
* @param string|null $title
* @return string
*/
public function title($title) {
$this->title = $title;
$this->forcetitle = true;
public function title(?string $title = null): string {
if ($title !== null) {
$this->title = $title;
$this->forcetitle = true;
}
return (string) $this->title;
}
/**