1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2019 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17declare(strict_types=1); 18 19namespace Fisharebest\Webtrees\Module; 20 21use Fisharebest\Webtrees\Menu; 22use Fisharebest\Webtrees\Tree; 23 24/** 25 * Trait ModuleMenuTrait - default implementation of ModuleMenuInterface 26 */ 27trait ModuleMenuTrait 28{ 29 /** @var int The default position for this menu. It can be changed in the control panel. */ 30 protected $menu_order; 31 32 /** 33 * Users change change the order of menus using the control panel. 34 * 35 * @param int $menu_order 36 * 37 * @return void 38 */ 39 public function setMenuOrder(int $menu_order): void 40 { 41 $this->menu_order = $menu_order; 42 } 43 44 /** 45 * Users change change the order of menus using the control panel. 46 * 47 * @return int 48 */ 49 public function getMenuOrder(): int 50 { 51 return $this->menu_order ?? $this->defaultMenuOrder(); 52 } 53 54 /** 55 * The default position for this menu. 56 * 57 * @return int 58 */ 59 public function defaultMenuOrder(): int 60 { 61 return 9999; 62 } 63 64 /** 65 * A menu, to be added to the main application menu. 66 * 67 * @param Tree $tree 68 * 69 * @return Menu|null 70 */ 71 public function getMenu(Tree $tree): ?Menu 72 { 73 return null; 74 } 75} 76