-
Notifications
You must be signed in to change notification settings - Fork 298
/
module.php
66 lines (54 loc) · 1.74 KB
/
module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Example theme. Here we are extending an existing theme.
* Instead, you could extend AbstractModule and implement ModuleThemeInterface directly.
*/
declare(strict_types=1);
namespace MyCustomNamespace;
use Fisharebest\Webtrees\Module\MinimalTheme;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
use Fisharebest\Webtrees\Module\ModuleCustomTrait;
use Fisharebest\Webtrees\View;
return new class extends MinimalTheme implements ModuleCustomInterface {
use ModuleCustomTrait;
/**
* @return string
*/
public function title(): string
{
return 'Custom theme';
}
/**
* Bootstrap the module
*/
public function boot(): void
{
// Register a namespace for our views.
View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/');
// Replace an existing view with our own version.
View::registerCustomView('::chart-box', $this->name() . '::chart-box');
}
/**
* Where does this module store its resources
*
* @return string
*/
public function resourcesFolder(): string
{
return __DIR__ . '/resources/';
}
/**
* Add our own stylesheet to the existing stylesheets.
*
* @return array<string>
*/
public function stylesheets(): array
{
$stylesheets = parent::stylesheets();
// NOTE - a future version of webtrees will allow the modules to be stored in a private folder.
// Only files in the /public/ folder will be accessible via the webserver.
// Since modules cannot copy their files to the /public/ folder, they need to provide them via a callback.
$stylesheets[] = $this->assetUrl('css/theme.css');
return $stylesheets;
}
};