Generate a label from the item type if none is provided

This commit is contained in:
vv221 2020-04-03 02:14:16 +02:00
parent 60f3dfe08f
commit 71295a3ec3
2 changed files with 6 additions and 3 deletions

View file

@ -11,9 +11,12 @@ class MenuItem extends AbstractItem {
* @param string $type
* @param string $label
*/
public function __construct(string $type, string $label) {
public function __construct(string $type, string $label = '') {
global $INFO;
$this->type = $type;
if ( empty($label) ) {
$label = ucfirst($type);
}
$this->label = $label;
parent::__construct();
// Edit the item to show a link to the requested children page

View file

@ -60,7 +60,7 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
* @param string $type
* @param string $name
*/
protected function addMenuItem(Doku_Event $event, string $type, string $name) {
protected function addMenuItem(Doku_Event $event, string $type, string $name = '') {
$item = $this->generateMenuItem($type, $name);
$event->data['items'][] = $item;
}
@ -70,7 +70,7 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
*
* @param string $type
*/
protected function generateMenuItem(string $type, string $name) {
protected function generateMenuItem(string $type, string $name = '') {
return new MenuItem($type, $name);
}
}