-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainPage.php
More file actions
63 lines (57 loc) · 1.81 KB
/
Copy pathMainPage.php
File metadata and controls
63 lines (57 loc) · 1.81 KB
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
<?php
declare(strict_types=1);
namespace ArrayAccess\TrayDigita\App\Modules\Core\Controllers;
use ArrayAccess\TrayDigita\Routing\AbstractController;
use ArrayAccess\TrayDigita\Routing\Attributes\All;
use ArrayAccess\TrayDigita\Routing\Attributes\Any;
use ArrayAccess\TrayDigita\Routing\Attributes\Group;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use function base64_decode;
#[Group('/')]
class MainPage extends AbstractController
{
#[Any('')]
public function main(
ResponseInterface $response
) : ResponseInterface {
return $this
->render(
'templates/home',
[],
$response
);
}
// handle favicon
/** @noinspection PhpUnusedParameterInspection */
#[All(
'(?:favicon\.(?:ico|png))',
name: 'favicon'
)]
public function favicon(
ServerRequestInterface $request,
ResponseInterface $response,
): ResponseInterface {
$this->getManager()
?->attach('response.sendPreviousBuffer', fn () => false);
$this->getManager()
?->attach('response.reduceError', fn () => true);
/** @noinspection SpellCheckingInspection */
$response->getBody()->write(
base64_decode(
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA1BMVEUAAACn'
. 'ej3aAAAAAXRSTlMAQObYZgAAAAtJREFUCNdjIBEAAAAwAAFletZ8AAAAAElFTkSuQmCC'
)
);
return $response->withHeader(
'Content-Type',
'image/png'
)->withHeader(
'Cache-Control',
'max-age=604800, public'
)->withHeader(
'Expires',
gmdate('D, d M Y H:i:s \G\M\T', time() + 86400)
)->withHeader('Pragma', 'public');
}
}