timer();
function returnOne()
{
return 1;
}
$cnt = 0;
for ($i = 0; $i < 1000; $i++) {
$cnt += returnOne();
}
timer();
class Test
{
public function returnOne()
{
return 1;
}
}
$testObject = new Test();
timer();
$cnt = 0;
for ($i = 0; $i < 1000; $i++) {
$cnt += $testObject->returnOne();
}
timer();
// [] фронтенд, ['logged'] закрытый фронтенд, ['logged', 'admin'] бэкенд
protected $authRoles = [];
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);
}
}
}