public function preDispatch(Request $req, Response $res) { $this->app->module = $this->chalk->module($req->group); $this->contentList = $this->hook->fire('core_contentList', new InfoList('core_main')); $this->widgetList = $this->hook->fire('core_widgetList', new InfoList()); $this->navList = $this->hook->fire('core_navList', new NavList()); $session = $this->session->data('__Chalk\\Backend'); if (!isset($session->user) && $req->controller !== 'auth') { $redirect = (string) $req->url()->toPart(Url::PART_PATH, true); return $res->redirect($this->url([], 'core_login', true) . $this->url->query(['redirect' => $redirect], true)); } $req->data = (object) []; $req->view = (object) []; if ($req->controller == 'auth') { return; } $req->user = $this->em('Chalk\\Core\\User')->id($session->user); if (!isset($req->user)) { $session->user = null; return $res->redirect($this->url([], 'core_login', true)); } $this->em->listener('core_trackable')->setUser($req->user); $saves = []; if (in_array("{$req->controller}__{$req->action}", $saves)) { $name = "query_" . md5(serialize($req->route['params'])); $params = $req->user->pref($name); unset($params['contentIds']); unset($params['batch']); if (isset($params)) { $req->queryParams($req->queryParams() + $params); } $params = $req->queryParams(); unset($params['contentIds']); unset($params['batch']); $req->user->pref($name, $params); $this->em->flush(); } }