35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
abstract class AdminController
|
|
{
|
|
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;
|
|
}
|
|
}
|