Automation/app/Controllers/Admin/AdminController.php
2024-09-05 17:22:34 +09:00

37 lines
1.1 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Controllers\BaseController;
abstract class AdminController extends BaseController
{
private $_datas = [];
protected function __construct()
{
//사용자 기본 Role 지정
$this->_datas[SESSION['NAMES']['ISLOGIN']] = false;
$this->_datas['currentRoles'] = [DEFAULTS["ROLE"]];
if ($this->_session->get(SESSION['NAMES']['ISLOGIN'])) {
$this->_datas[SESSION['NAMES']['ISLOGIN']] = true;
$this->_datas['auth'] = $this->_session->get(SESSION['NAMES']['AUTH']);
$currentRoles = explode(DEFAULTS['DELIMITER_ROLE'], $this->_datas['auth'][AUTH['FIELDS']['ROLE']]);
$this->_datas['currentRoles'] = is_array($currentRoles) ? $currentRoles : [DEFAULTS["ROLE"]];
}
}
final public function __get($name): array|null
{
if (!array_key_exists($name, $this->_datas)) {
return null;
}
return $this->_datas;
}
final public function __set($name, $value): void
{
$this->_datas[$name] = $value;
}
}