PHP_SMART_HOME_V3/app/class/Route.php

31 lines
564 B
PHP
Raw Permalink Normal View History

2019-08-23 11:39:42 +00:00
<?php
class Route{
private $urls = [];
private $views = [];
function __construct() {
// code...
}
function add($url, $view = "", $conrol = "") {
$this->urls[] = '/'.trim($url, '/');
if (!empty($view)) {
$this->views[] = $view;
}
}
function submit(){
$urlGetParam = isset($_GET['url']) ? '/' . $_GET['url'] : '/';
foreach ($this->urls as $urlKey => $urlValue) {
if ($urlValue === $urlGetParam) {
$useView = $this->views[$urlKey];
new $useView();
2019-09-01 13:55:33 +00:00
die();
2019-08-23 11:39:42 +00:00
}
}
2019-09-01 13:55:33 +00:00
echo 'Not Fount 404';
die();
//TODO: 404 přidělat
2019-08-23 11:39:42 +00:00
}
}