App\Controllers\Admin\BaseController::initRoute PHP Method

initRoute() protected method

protected initRoute ( $req, $res )
    protected function initRoute($req, $res)
    {
        $this->request = $req;
        $this->response = $res;
        $s = $req->getAttribute('route')->getName();
        $this->data['current_route_name'] = $s;
        $this->containerSlim->get('logger')->addInfo("Run admin page: ", [Session::get('user')['login']]);
        $this->containerSlim->get('logger')->addInfo("Get route: ", [$s]);
        $model = ModelsFactory::getModel('UserViewsSettings');
        $result = $model->where('user_id', Session::get('user')['id'])->where('group', 'last.page.' . basename($req->getUri()->getPath()))->where('code', 'page')->first();
        if ($result) {
            $current_page = $result->value;
        }
        Paginator::currentPageResolver(function () use($current_page) {
            return $current_page;
        });
        $result = $model->where('user_id', Session::get('user')['id'])->where('group', 'items.perpage.' . basename($req->getUri()->getPath()))->where('code', 'count_page')->first();
        if ($result) {
            $this->pagecount = $result->value;
            $this->data['page_count'] = $this->pagecount;
        }
        $result = $model->where('user_id', Session::get('user')['id'])->where('group', 'order.type.' . basename($req->getUri()->getPath()))->where('code', 'order_by')->first();
        $this->pageOrderBy = "id";
        if ($result) {
            $this->pageOrderBy = $result->value;
        }
        $this->data['page_order_by'] = $this->pageOrderBy;
        $result = $model->where('user_id', Session::get('user')['id'])->where('group', 'order.type.' . basename($req->getUri()->getPath()))->where('code', 'order_type')->first();
        $this->pageOrderType = "asc";
        if ($result) {
            $this->pageOrderType = $result->value;
        }
        $this->data['page_order_type'] = $this->pageOrderType;
        if (!$this->controllerName) {
            $this->controllerName = substr($s, strpos($s, '.') + 1);
        }
        $this->init();
        $this->csrf($req);
    }