xref: /webtrees/app/Module/ModuleBlockInterface.php (revision 0c0910bf0f275a14f35d2ccdf698f91f79e269d4)
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\Tree;
22use Psr\Http\Message\ServerRequestInterface;
23
24/**
25 * Interface ModuleBlockInterface - Classes and libraries for module system
26 */
27interface ModuleBlockInterface extends ModuleInterface
28{
29    // Places we can display blocks
30    public const CONTEXT_EMBED     = 'embed';
31    public const CONTEXT_TREE_PAGE = 'tree';
32    public const CONTEXT_USER_PAGE = 'user';
33
34    /**
35     * Generate the HTML content of this block.
36     *
37     * @param Tree   $tree
38     * @param int    $block_id
39     * @param string $context
40     * @param array  $config
41     *
42     * @return string
43     */
44    public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string;
45
46    /**
47     * Should this block load asynchronously using AJAX?
48     *
49     * Simple blocks are faster in-line, more complex ones can be loaded later.
50     *
51     * @return bool
52     */
53    public function loadAjax(): bool;
54
55    /**
56     * Can this block be shown on the user’s home page?
57     *
58     * @return bool
59     */
60    public function isUserBlock(): bool;
61
62    /**
63     * Can this block be shown on the tree’s home page?
64     *
65     * @return bool
66     */
67    public function isTreeBlock(): bool;
68
69    /**
70     * An HTML form to edit block settings
71     *
72     * @param Tree $tree
73     * @param int  $block_id
74     *
75     * @return string
76     */
77    public function editBlockConfiguration(Tree $tree, int $block_id): string;
78
79    /**
80     * Update the configuration for a block.
81     *
82     * @param ServerRequestInterface $request
83     * @param int     $block_id
84     *
85     * @return void
86     */
87    public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void;
88}
89