xref: /webtrees/app/Module/ModuleSidebarTrait.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
149a243cbSGreg Roach<?php
23976b470SGreg Roach
349a243cbSGreg Roach/**
449a243cbSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
649a243cbSGreg Roach * This program is free software: you can redistribute it and/or modify
749a243cbSGreg Roach * it under the terms of the GNU General Public License as published by
849a243cbSGreg Roach * the Free Software Foundation, either version 3 of the License, or
949a243cbSGreg Roach * (at your option) any later version.
1049a243cbSGreg Roach * This program is distributed in the hope that it will be useful,
1149a243cbSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1249a243cbSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1349a243cbSGreg Roach * GNU General Public License for more details.
1449a243cbSGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
1649a243cbSGreg Roach */
17fcfa147eSGreg Roach
1849a243cbSGreg Roachdeclare(strict_types=1);
1949a243cbSGreg Roach
2049a243cbSGreg Roachnamespace Fisharebest\Webtrees\Module;
2149a243cbSGreg Roach
22db39ef31SGreg Roachuse Fisharebest\Webtrees\Individual;
238eaf8709SGreg Roachuse Illuminate\Support\Collection;
248eaf8709SGreg Roach
2549a243cbSGreg Roach/**
2649a243cbSGreg Roach * Trait ModuleSidebarTrait - default implementation of ModuleSidebarInterface
2749a243cbSGreg Roach */
2849a243cbSGreg Roachtrait ModuleSidebarTrait
2949a243cbSGreg Roach{
3033c746f1SGreg Roach    // The default position for this sidebar.  It can be changed in the control panel.
3133c746f1SGreg Roach    protected int $sidebar_order;
3249a243cbSGreg Roach
3349a243cbSGreg Roach    /**
34bfed30e4SGreg Roach     * How should this module be identified in the control panel, etc.?
35bfed30e4SGreg Roach     *
36bfed30e4SGreg Roach     * @return string
37bfed30e4SGreg Roach     */
38bfed30e4SGreg Roach    abstract public function title(): string;
39bfed30e4SGreg Roach
40bfed30e4SGreg Roach    /**
4139402588SGreg Roach     * The text that appears on the sidebar's title.
4239402588SGreg Roach     *
43db39ef31SGreg Roach     * @param Individual $individual
44db39ef31SGreg Roach     *
4539402588SGreg Roach     * @return string
4639402588SGreg Roach     */
4749528f2bSGreg Roach    public function sidebarTitle(Individual $individual): string
4839402588SGreg Roach    {
4939402588SGreg Roach        return $this->title();
5039402588SGreg Roach    }
5139402588SGreg Roach
5239402588SGreg Roach    /**
5349a243cbSGreg Roach     * Users change change the order of sidebars using the control panel.
5449a243cbSGreg Roach     *
5549a243cbSGreg Roach     * @param int $sidebar_order
5649a243cbSGreg Roach     *
5749a243cbSGreg Roach     * @return void
5849a243cbSGreg Roach     */
5949a243cbSGreg Roach    public function setSidebarOrder(int $sidebar_order): void
6049a243cbSGreg Roach    {
6149a243cbSGreg Roach        $this->sidebar_order = $sidebar_order;
6249a243cbSGreg Roach    }
6349a243cbSGreg Roach
6449a243cbSGreg Roach    /**
6549a243cbSGreg Roach     * Users change change the order of sidebars using the control panel.
6649a243cbSGreg Roach     *
6749a243cbSGreg Roach     * @return int
6849a243cbSGreg Roach     */
6949a243cbSGreg Roach    public function getSidebarOrder(): int
7049a243cbSGreg Roach    {
7124bd2cf5SGreg Roach        return $this->sidebar_order ?? $this->defaultSidebarOrder();
7249a243cbSGreg Roach    }
7349a243cbSGreg Roach
7449a243cbSGreg Roach    /**
75fceda430SGreg Roach     * The default position for this sidebar.
7649a243cbSGreg Roach     *
7749a243cbSGreg Roach     * @return int
7849a243cbSGreg Roach     */
79c1afbf58SGreg Roach    public function defaultSidebarOrder(): int
8049a243cbSGreg Roach    {
8149a243cbSGreg Roach        return 9999;
8249a243cbSGreg Roach    }
838eaf8709SGreg Roach
848eaf8709SGreg Roach    /**
858eaf8709SGreg Roach     * This module handles the following facts - so don't show them on the "Facts and events" tab.
868eaf8709SGreg Roach     *
8736779af1SGreg Roach     * @return Collection<int,string>
888eaf8709SGreg Roach     */
898eaf8709SGreg Roach    public function supportedFacts(): Collection
908eaf8709SGreg Roach    {
91075d1a05SGreg Roach        return new Collection();
928eaf8709SGreg Roach    }
9349a243cbSGreg Roach}
94