-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExampleModuleFooter.php
85 lines (73 loc) · 2.14 KB
/
ExampleModuleFooter.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* Example footer with a link to a page of information.
*/
declare(strict_types=1);
namespace ExampleNamespace;
use Fisharebest\Webtrees\Module\AbstractModule;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
use Fisharebest\Webtrees\Module\ModuleCustomTrait;
use Fisharebest\Webtrees\Module\ModuleFooterInterface;
use Fisharebest\Webtrees\Module\ModuleFooterTrait;
use Fisharebest\Webtrees\View;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class ExampleModuleFooter extends AbstractModule implements ModuleCustomInterface, ModuleFooterInterface {
use ModuleCustomTrait;
use ModuleFooterTrait;
/**
* @return string
*/
public function title(): string
{
return 'Custom footer';
}
/**
* Bootstrap the module
*/
public function boot(): void
{
// Register a namespace for our views.
View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/');
}
/**
* Where does this module store its resources
*
* @return string
*/
public function resourcesFolder(): string
{
return __DIR__ . '/resources/';
}
/**
* A footer, to be added at the bottom of every page.
*
* @param ServerRequestInterface $request
*
* @return string
*/
public function getFooter(ServerRequestInterface $request): string
{
$tree = $request->getAttribute('tree');
$url = route('module', [
'module' => $this->name(),
'action' => 'Page',
'tree' => $tree ? $tree->name() : null,
]);
return view($this->name() . '::footer', ['url' => $url]);
}
/**
* Generate the page that will be shown when we click the link in the footer.
*
* @param ServerRequestInterface $request
*
* @return ResponseInterface
*/
public function getPageAction(ServerRequestInterface $request): ResponseInterface
{
return $this->viewResponse($this->name() . '::page', [
'title' => $this->title(),
'tree' => $request->getAttribute('tree'),
]);
}
};