xref: /webtrees/app/Module/ModuleBlockInterface.php (revision 3eae54c8a20b98985facfcff8d58c982338bbf85)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Module;
19
20use Fisharebest\Webtrees\Tree;
21use Psr\Http\Message\ServerRequestInterface;
22
23/**
24 * Interface ModuleBlockInterface - Classes and libraries for module system
25 */
26interface ModuleBlockInterface extends ModuleInterface
27{
28    // Places we can display blocks
29    public const CONTEXT_EMBED     = 'embed';
30    public const CONTEXT_TREE_PAGE = 'tree';
31    public const CONTEXT_USER_PAGE = 'user';
32
33    /**
34     * Generate the HTML content of this block.
35     *
36     * @param Tree   $tree
37     * @param int    $block_id
38     * @param string $context
39     * @param array  $config
40     *
41     * @return string
42     */
43    public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string;
44
45    /**
46     * Should this block load asynchronously using AJAX?
47     *
48     * Simple blocks are faster in-line, more complex ones can be loaded later.
49     *
50     * @return bool
51     */
52    public function loadAjax(): bool;
53
54    /**
55     * Can this block be shown on the user’s home page?
56     *
57     * @return bool
58     */
59    public function isUserBlock(): bool;
60
61    /**
62     * Can this block be shown on the tree’s home page?
63     *
64     * @return bool
65     */
66    public function isTreeBlock(): bool;
67
68    /**
69     * An HTML form to edit block settings
70     *
71     * @param Tree $tree
72     * @param int  $block_id
73     *
74     * @return string
75     */
76    public function editBlockConfiguration(Tree $tree, int $block_id): string;
77
78    /**
79     * Update the configuration for a block.
80     *
81     * @param ServerRequestInterface $request
82     * @param int     $block_id
83     *
84     * @return void
85     */
86    public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void;
87}
88