blob: ac1e45830b1eaaa7d5297f55e4098d96a63ac4eb (
plain)
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
|
<?php /* Copyright (c) 2024 Freya Murphy */
abstract class Controller extends Component {
/**
* Default index for a app, empty
*/
public function index(): void {}
/**
* Redirectes to a link
*/
public function redirect(string $link): void
{
header('Location: '. $link, true, 301);
die();
}
/**
* Lodas a view
*/
protected function view(string $__name, array $data = array()): void
{
$__path = WEB_ROOT . '/_views/' . $__name . '.php';
if (is_file($__path)) {
extract($data);
require($__path);
}
}
/**
* Loads a erorr page with a given
* error code
*/
protected function error(int $code): void
{
$error_controller = $this->load_controller('error');
$error_controller->code($code);
die();
}
}
|