philippurbschat.de/home/app/controllers/HomeController.php

28 lines
No EOL
820 B
PHP

<?php
require_once __DIR__ . '/../../core/Controller.php';
class HomeController extends Controller {
// Main Route Handler
public function index($name = 'home') {
$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');
}
}