/
vagan
/
Framework
Обзор
Документация
Войти
/
vagan
/
Framework
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
application/core/Controller.php
59 строк
1 KB
Vagan
End of framework development
01 мар 2021, 15:25
01 мар 2021, 15:25
a241e9e
Код
Авторство
О чём код?
<?php namespace application\core; use application\core\View; abstract class Controller { public $route; public $view; public $acl; public function __construct($route) { $this->route = $route; if(!$this->checkAcl()) { View::errorCode(403); } $this->view = new View($route); $this->model = $this->loadModel($route['controller']); //$this->before(); } public function loadModel($name) { $path = 'application\models\\' . ucfirst($name); if (class_exists($path)) { return new $path; } } public function checkAcl() { $path = 'application/acl/' . $this->route['controller'] . '.php'; if (file_exists($path)) { $this->acl = require $path; if ($this->isAcl('all')) { return true; } elseif (isset($_SESSION['authorize']['id']) && $this->isAcl('authorize')) { return true; } elseif (!isset($_SESSION['authorize']['id']) && $this->isAcl('guest')) { return true; } elseif (isset($_SESSION['admin']) && $this->isAcl('admin')) { return true; } return false; } } public function isAcl($key) { return in_array($this->route['action'], $this->acl[$key]); } }