Skip to content

Commit 25973cd

Browse files
authored
Align with current 2.1 code (#1)
1 parent c1c60be commit 25973cd

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

ExampleModuleCustomTags.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace ExampleNamespace;
1010

11-
use Fisharebest\Webtrees\Contracts\ElementInterface;
1211
use Fisharebest\Webtrees\Elements\AddressWebPage;
1312
use Fisharebest\Webtrees\Elements\CustomElement;
1413
use Fisharebest\Webtrees\Elements\EmptyElement;
@@ -18,9 +17,8 @@
1817
use Fisharebest\Webtrees\I18N;
1918
use Fisharebest\Webtrees\Module\AbstractModule;
2019
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
21-
use Fisharebest\Webtrees\Module\ModuleCustomTagsInterface;
22-
use Fisharebest\Webtrees\Module\ModuleCustomTagsTrait;
2320
use Fisharebest\Webtrees\Module\ModuleCustomTrait;
21+
use Fisharebest\Webtrees\Registry;
2422

2523
/**
2624
* Class ExampleModuleCustomTags
@@ -30,11 +28,10 @@
3028
*
3129
* Modules *must* implement ModuleCustomInterface. They *may* also implement other interfaces.
3230
*/
33-
class ExampleModuleCustomTags extends AbstractModule implements ModuleCustomTagsInterface, ModuleCustomInterface
31+
class ExampleModuleCustomTags extends AbstractModule implements ModuleCustomInterface
3432
{
3533
// For every module interface that is implemented, the corresponding trait *should* also use be used.
3634
use ModuleCustomTrait;
37-
use ModuleCustomTagsTrait;
3835

3936
/**
4037
* How should this module be identified in the control panel, etc.?
@@ -117,10 +114,20 @@ public function customTranslations(string $language): array
117114
}
118115
}
119116

117+
/**
118+
* Called for all *enabled* modules.
119+
*/
120+
public function boot(): void
121+
{
122+
$elementFactory = Registry::elementFactory();
123+
$elementFactory->registerTags($this->customTags());
124+
$elementFactory->registerSubTags($this->customSubTags());
125+
}
126+
120127
/**
121128
* @return array<string,ElementInterface>
122129
*/
123-
public function customTags(): array
130+
protected function customTags(): array
124131
{
125132
return [
126133
'FAM:DATA' => new EmptyElement(I18N::translate('Data'), ['TEXT' => '0:1']),
@@ -139,7 +146,7 @@ public function customTags(): array
139146
/**
140147
* @return array<string,array<int,array<int,string>>>
141148
*/
142-
public function customSubTags(): array
149+
protected function customSubTags(): array
143150
{
144151
return [
145152
'FAM' => [['DATA', '0:M']],

0 commit comments

Comments
 (0)