-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAddOn.php
52 lines (45 loc) · 1.16 KB
/
AddOn.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
<?php
/**
* Author and copyright: Stefan Haack (https://shaack.com)
* Repository: https://github.com/shaack/reboot-cms
* License: MIT, see file 'LICENSE'
*/
namespace Shaack\Reboot;
/**
* Overwrite the init(), preRender() and postRender() to add functionality
* to your Site.
*/
class AddOn
{
protected Reboot $reboot;
protected Site $site;
public function __construct(Reboot $reboot, Site $site)
{
$this->reboot = $reboot;
$this->site = $site;
$this->init();
}
/**
* Called after construction of the AddOn
* @return void
*/
protected function init()
{
}
/**
* Called on every request before rendering the page.
* Return true, if you want to render the page or false if you do a redirect or deny access.
*/
public function preRender(Request $request): bool
{
return true;
}
/**
* Called after the page is rendered before displaying it. Use it to modify content after rendering.
* Returns the modified content of the page.
*/
public function postRender(Request $request, string $content): string
{
return $content;
}
}