xref: /webtrees/app/Module/ModuleSidebarTrait.php (revision 1c6adce825f16611bd8b75a22114302de4b41cfe)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 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 <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Module;
21
22use Fisharebest\Webtrees\Individual;
23use Illuminate\Support\Collection;
24
25/**
26 * Trait ModuleSidebarTrait - default implementation of ModuleSidebarInterface
27 */
28trait ModuleSidebarTrait
29{
30    // The default position for this sidebar.  It can be changed in the control panel.
31    protected int $sidebar_order;
32
33    /**
34     * The text that appears on the sidebar's title.
35     *
36     * @param Individual $individual
37     *
38     * @return string
39     */
40    public function sidebarTitle(/** @scrutinizer ignore-unused */ Individual $individual): string
41    {
42        return $this->title();
43    }
44
45    /**
46     * Users change change the order of sidebars using the control panel.
47     *
48     * @param int $sidebar_order
49     *
50     * @return void
51     */
52    public function setSidebarOrder(int $sidebar_order): void
53    {
54        $this->sidebar_order = $sidebar_order;
55    }
56
57    /**
58     * Users change change the order of sidebars using the control panel.
59     *
60     * @return int
61     */
62    public function getSidebarOrder(): int
63    {
64        return $this->sidebar_order ?? $this->defaultSidebarOrder();
65    }
66
67
68    /**
69     * The default position for this sidebar.
70     *
71     * @return int
72     */
73    public function defaultSidebarOrder(): int
74    {
75        return 9999;
76    }
77
78    /**
79     * This module handles the following facts - so don't show them on the "Facts and events" tab.
80     *
81     * @return Collection<string>
82     */
83    public function supportedFacts(): Collection
84    {
85        return new Collection();
86    }
87}
88