class AuthController extends AppController {}
class PageController extends AppController {}
class BackendPageController extends AuthController {}
abstract class AuthController extends Controller
abstract class AuthController
{
// [] фронтенд, ['logged'] закрытый фронтенд, ['logged', 'admin'] бэкенд
protected $authRoles = [];
protected function checkAuth()
{
$auth = Auth::instance($_SESSION ?? []);
if (! $auth->getUser()) {
throw new HttpException(null, 401);
}
if (! $auth->loggedIn($this->authRoles)) {
throw new HttpException(null, 403);
}
}
}
public sfunction overwrite(array $array, array ...$arrays): array
{
$intersected = array_intersect_key(array_replace(...$arrays), $array);
return array_replace($array, $intersected);
}
$file = __DIR__ . '/demo.php';
$config = \PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one',],
'list_syntax' => ['syntax' => 'short'],
])
->setFinder(new ArrayIterator([new SplFileInfo($file)]));
$resolver = new \PhpCsFixer\Console\ConfigurationResolver(
$config,
[],
__DIR__,
new \PhpCsFixer\ToolInfo()
);
$runner = new \PhpCsFixer\Runner\Runner(
$config->getFinder(),
$resolver->getFixers(),
$resolver->getDiffer(),
null,
new \PhpCsFixer\Error\ErrorsManager(),
$resolver->getLinter(),
$resolver->isDryRun(),
$resolver->getCacheManager(),
$resolver->getDirectory(),
$resolver->shouldStopOnViolation()
);
$runner->fix();