|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
5
|
|
|
* |
|
6
|
|
|
* @package MyArtJaub\Webtrees |
|
7
|
|
|
* @subpackage Hooks |
|
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
|
9
|
|
|
* @copyright Copyright (c) 2011-2022, Jonathan Jaubart |
|
10
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace MyArtJaub\Webtrees\Module\Hooks\Hooks; |
|
16
|
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\I18N; |
|
18
|
|
|
use Fisharebest\Webtrees\Individual; |
|
19
|
|
|
use MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector; |
|
20
|
|
|
use MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Hook collector for hooks implementing NameAccordionExtenderInterface. |
|
24
|
|
|
* Used to extend the names accordion on the individual page. |
|
25
|
|
|
* |
|
26
|
|
|
* @extends AbstractHookCollector<NameAccordionExtenderInterface> |
|
27
|
|
|
*/ |
|
28
|
|
|
class NameAccordionExtenderCollector extends AbstractHookCollector implements NameAccordionExtenderInterface |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritDoc} |
|
32
|
|
|
* @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::title() |
|
33
|
|
|
*/ |
|
34
|
|
|
public function title(): string |
|
35
|
|
|
{ |
|
36
|
|
|
return I18N::translate('Individual names accordion extender'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritDoc} |
|
41
|
|
|
* @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::description() |
|
42
|
|
|
*/ |
|
43
|
|
|
public function description(): string |
|
44
|
|
|
{ |
|
45
|
|
|
return I18N::translate('Extends the names accordion of on an individual’s page.'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* {@inheritDoc} |
|
50
|
|
|
* @see \MyArtJaub\Webtrees\Common\Hooks\AbstractHookCollector::hookInterface() |
|
51
|
|
|
*/ |
|
52
|
|
|
public function hookInterface(): string |
|
53
|
|
|
{ |
|
54
|
|
|
return NameAccordionExtenderInterface::class; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritDoc} |
|
59
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\NameAccordionExtenderInterface::accordionCard() |
|
60
|
|
|
*/ |
|
61
|
|
|
public function accordionCard(Individual $individual): string |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->hooks() |
|
64
|
|
|
->map(fn(NameAccordionExtenderInterface $hook) => $hook->accordionCard($individual)) |
|
65
|
|
|
->implode(''); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|