38 lines
No EOL
1.2 KiB
PHP
38 lines
No EOL
1.2 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../../core/Controller.php';
|
|
class HomeController extends Controller {
|
|
// Main Route Handler
|
|
public function index($name = 'home') {
|
|
if ($name === 'robots.txt') {
|
|
require_once __DIR__ . '/SeoController.php';
|
|
$seo = new SeoController();
|
|
return $seo->robots();
|
|
}
|
|
if ($name === 'sitemap.xml') {
|
|
require_once __DIR__ . '/SeoController.php';
|
|
$seo = new SeoController();
|
|
return $seo->sitemap();
|
|
}
|
|
$routeName = str_replace(['.xml', '.txt'], '', $name);
|
|
$allowedRoutes = ['about', 'imprint', 'privacy'];
|
|
if (in_array($routeName, $allowedRoutes)) {
|
|
return $this->{$routeName}();
|
|
}
|
|
if ($routeName !== 'home' && $routeName !== '') {
|
|
throw new Exception("Route not found.");
|
|
}
|
|
$this->view('home', [
|
|
'name' => $name
|
|
]);
|
|
}
|
|
// Static Views
|
|
public function about() {
|
|
$this->view('about');
|
|
}
|
|
public function imprint() {
|
|
$this->view('imprint');
|
|
}
|
|
public function privacy() {
|
|
$this->view('privacy');
|
|
}
|
|
} |