xref: /webtrees/app/Module/ModuleSidebarTrait.php (revision 49a243cb5fe7c21b24e262552d556b018bfe3f41)
1*49a243cbSGreg Roach<?php
2*49a243cbSGreg Roach/**
3*49a243cbSGreg Roach * webtrees: online genealogy
4*49a243cbSGreg Roach * Copyright (C) 2019 webtrees development team
5*49a243cbSGreg Roach * This program is free software: you can redistribute it and/or modify
6*49a243cbSGreg Roach * it under the terms of the GNU General Public License as published by
7*49a243cbSGreg Roach * the Free Software Foundation, either version 3 of the License, or
8*49a243cbSGreg Roach * (at your option) any later version.
9*49a243cbSGreg Roach * This program is distributed in the hope that it will be useful,
10*49a243cbSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*49a243cbSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12*49a243cbSGreg Roach * GNU General Public License for more details.
13*49a243cbSGreg Roach * You should have received a copy of the GNU General Public License
14*49a243cbSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15*49a243cbSGreg Roach */
16*49a243cbSGreg Roachdeclare(strict_types=1);
17*49a243cbSGreg Roach
18*49a243cbSGreg Roachnamespace Fisharebest\Webtrees\Module;
19*49a243cbSGreg Roach
20*49a243cbSGreg Roach/**
21*49a243cbSGreg Roach * Trait ModuleSidebarTrait - default implementation of ModuleSidebarInterface
22*49a243cbSGreg Roach */
23*49a243cbSGreg Roachtrait ModuleSidebarTrait
24*49a243cbSGreg Roach{
25*49a243cbSGreg Roach    /** @var int The default position for this sidebar.  It can be changed in the control panel. */
26*49a243cbSGreg Roach    protected $sidebar_order = 0;
27*49a243cbSGreg Roach
28*49a243cbSGreg Roach    /**
29*49a243cbSGreg Roach     * Users change change the order of sidebars using the control panel.
30*49a243cbSGreg Roach     *
31*49a243cbSGreg Roach     * @param int $sidebar_order
32*49a243cbSGreg Roach     *
33*49a243cbSGreg Roach     * @return void
34*49a243cbSGreg Roach     */
35*49a243cbSGreg Roach    public function setSidebarOrder(int $sidebar_order): void
36*49a243cbSGreg Roach    {
37*49a243cbSGreg Roach        $this->sidebar_order = $sidebar_order;
38*49a243cbSGreg Roach    }
39*49a243cbSGreg Roach
40*49a243cbSGreg Roach    /**
41*49a243cbSGreg Roach     * Users change change the order of sidebars using the control panel.
42*49a243cbSGreg Roach     *
43*49a243cbSGreg Roach     * @return int
44*49a243cbSGreg Roach     */
45*49a243cbSGreg Roach    public function getSidebarOrder(): int
46*49a243cbSGreg Roach    {
47*49a243cbSGreg Roach        return $this->sidebar_order ?: $this->defaultSidebarOrder();
48*49a243cbSGreg Roach    }
49*49a243cbSGreg Roach
50*49a243cbSGreg Roach
51*49a243cbSGreg Roach    /**
52*49a243cbSGreg Roach     * The default position for this sdiebar.
53*49a243cbSGreg Roach     *
54*49a243cbSGreg Roach     * @return int
55*49a243cbSGreg Roach     */
56*49a243cbSGreg Roach    function defaultSidebarOrder(): int
57*49a243cbSGreg Roach    {
58*49a243cbSGreg Roach        return 9999;
59*49a243cbSGreg Roach    }
60*49a243cbSGreg Roach}
61