1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-22 03:32:47 +08:00
xiaochong0302 0342331d89 1.重命名kg_img_url
2.调整错误页
3.模拟topic数据
2020-04-12 17:27:33 +08:00

70 lines
1.6 KiB
PHP

<?php
namespace App\Http\Web\Controllers;
use App\Caches\NavTreeList as NavTreeListCache;
use App\Caches\Setting as SettingCache;
use App\Services\Auth\Web as WebAuth;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
use Phalcon\Mvc\Dispatcher;
class Controller extends \Phalcon\Mvc\Controller
{
protected $siteSettings;
protected $navList;
protected $authUser;
use ResponseTrait, SecurityTrait;
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
if ($this->isNotSafeRequest()) {
$this->checkHttpReferer();
$this->checkCsrfToken();
}
$this->checkRateLimit();
$this->siteSettings = $this->getSiteSettings();
$this->navList = $this->getNavList();
$this->authUser = $this->getAuthUser();
return true;
}
public function initialize()
{
$this->view->setVar('auth_user', $this->authUser);
$this->view->setVar('site_settings', $this->siteSettings);
$this->view->setVar('top_nav_list', $this->navList->top);
$this->view->setVar('btm_nav_list', $this->navList->bottom);
}
protected function getAuthUser()
{
/**
* @var WebAuth $auth
*/
$auth = $this->getDI()->get('auth');
return $auth->getAuthInfo();
}
protected function getNavList()
{
$cache = new NavTreeListCache();
return $cache->get();
}
protected function getSiteSettings()
{
$cache = new SettingCache();
return $cache->get('site');
}
}