Initializer of pager objects from request query parameters.

@param Request $request

@throws PagerOverrideException
11814
public function initialize(Request $request)
    {
        // prevent reinit
        if (!$this->request) {
            $this->request = $request;
            $pagers = $this->decodeHttpQuery();
            // prevent pager override
            if (array_intersect_key($pagers, $this->pagers)) {
                throw new PagerOverrideException();
            }

            $this->pagers = $pagers;
        }
    }
1348525
public function handleRequest(Request $request, Page &$page)
    {
        $page->setData([
            "link" => $request->request->get("vfou_cmsbundle_page")["link"],
            "code" => $request->request->get("vfou_cmsbundle_page")["code"]
        ]);
    }
130661
public function createPager(QueryBuilder $qb, Request $request)
    {
        // Too bad we can't use the Sidus/FilterBundle DoctrineORMAdapter instead but it's not a dependency
        $pager = new Pagerfanta(new DoctrineORMAdapter($qb, false));
        /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
        $pager->setMaxPerPage(10);
        try {
            $pager->setCurrentPage($request->get('page', 1));
        } catch (NotValidCurrentPageException $e) {
            // Silence exception, fallback to first page
        }

        return $pager;
    }
554244
public function setRequest( Request $request )
	{
		$this->request = $request;

		$this->cachedRoot = null;
		$this->cachedSchema = null;
	}
361533
public function postChildren(Request $request, Page $page)
    {
        $this->authorize('editChildrenBasic', $page);

        $post = $request->input();

        $page->setChildTemplateId($request->input('children_template_id'));

        if (Gate::allows('editChildrenAdvanced', $page)) {
            $page
                ->setChildrenUrlPrefix($request->input('children_url_prefix'))
                ->setChildrenVisibleInNav($request->has('children_visible_in_nav'))
                ->setChildrenVisibleInNavCms($request->has('children_visible_in_nav_cms'))
                ->setGrandchildTemplateId($request->input('grandchild_template_id'));
        }

        if (isset($post['children_ordering_policy']) && isset($post['children_ordering_direction'])) {
            $page->setChildOrderingPolicy($post['children_ordering_policy'], $post['children_ordering_direction']);
        }

        PageFacade::save($page);
    }
478546
public function parseRequest(Request $request)
    {
        try {
            $this->setPath($request->get('_route'));

            $this->setQuery($request->query->all());

            $this->setRouteParams($request->attributes->get('_route_params'));

            if ($request->get('page')) {
                $this->setCurrentPage((int)$request->get('page'));
            }

            if ($request->get('maxItems')) {
                $this->setNumberOfElementsPerPage((int)$request->get('maxItems'));
            }

        } catch (\Exception $e) {
            throw new \Exception ('The request provided is not a valid Request Object');
        }

        return $this;
    }
1163768
protected function init(Request $request = null, Response $response = null, array $user_options = array())
    {
        $this->setUserOptions(
            $this->extendOptions($user_options)
        );
        foreach (array('tmp_directory', 'var_directory', 'log_directory') as $_dir) {
            DirectoryHelper::ensureExists($this->getOption($_dir));
        }
        $this->setLogger(
            new Logger($this->getLoggerOptions())
        );
        if (!is_null($request)) {
            $this->setRequest($request);
        }
        if (!is_null($response)) {
            $this->setResponse($response);
        }
        $this->getResponse()->setContentType('json');
        if ($this->getOption('enable_url_rewrite')===true) {
            $this->getRequest()
                ->setFlag(Request::REWRITE_SEGMENTS_QUERY)
                ->setArguments($this->getRequest()->getArguments())
                ;
        }
/*
echo '<pre>';
var_export($this->getRequest());
exit('yo');
*/
    }
789377
protected function setRequestProperties(Request $request)
    {
        $this["basePath"] = $request->getBasePath();
        $this["baseUrl"] = $request->getSchemeAndHttpHost() . $this["basePath"];
    }
171131
protected function startSession(Request $request)
    {
        $this->gc();
        $this->session->setId($request->getCookies()->get($this->session->getName()));
        $this->sessionHandler->open(null, $this->session->getName());
        $sessionVars = @unserialize($this->sessionHandler->read($this->session->getId()));

        if ($sessionVars === false) {
            $sessionVars = [];
        }

        $this->session->start($sessionVars);
    }
856662
public function create(PageRequest $request)
    {

        $page = $this->repository->newInstance([]);
        return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('page::page.name')) 
            ->view('page::page.create', true) 
            ->data(compact('page'))
            ->output();
    }
948968
public function index(Request $request)
    {
        // handle permission
//        list($request, $filters) = $this->handlePermission(__FUNCTION__, $request);

        // create response model
        $response = new ResponseModel();

        $pageSize = $this->DEFAULT_RESULT_PER_PAGE;

        $pageNumber = 1;

        //set default pagination

        //set page size
        if (!isset($request->toArray()['page']['size'])) {
            $pageSize = $this->DEFAULT_RESULT_PER_PAGE;
        } elseif (($request->get('page')['size']) == 0) {
            $pageSize = $this->DEFAULT_RESULT_PER_PAGE;
        } else {
            $pageSize = $request->get('page')['size'];
        }

        //set page number
        if (!isset($request->get('page')['number'])) {
            $pageNumber = $this->DEFAULT_PAGE_NUMBER;
        } elseif (($request->get('page')['number']) == 0) {
            $pageNumber = $this->DEFAULT_PAGE_NUMBER;
        } else {
            $pageNumber = $request->get('page')['number'];
        }
        $request['page'] = $pageNumber;


        //set default ordering
        if (isset($request->toArray()['order_by'])) {
            if (is_null($request['order_by'])) {
                $request['order_by'] = "{\"field\":\"id\",\"operator\":\"Desc\"}";
            }
        }

        $validationErrors = $this->checkRequestValidation($request, $this->indexValidateArray);
        if ($validationErrors != null) {
            if (env('APP_DEBUG', false)) {
                $response->setData(collect($validationErrors->toArray()));
            }
            $response->setMessage($this->getTrans(__FUNCTION__, 'validation_failed'));
            $response->setStatus(false);
            $response->setError(99);
            return SmartResponse::response($response);
        }

        try {
            $data = $request->get('query') != null ?
                $this->model
                    ->whereKey(collect($this->model
                        ->search(($request->get('query')))
                        ->raw())->get('ids')) :
                $this->model;

            if (array_key_exists('file', $request->toArray())) {
                //TODO add relation on top if here and create a tree flatter array in array helper
                //return (new ExcelHelper())->setOptions([
                //    'store_format' => $request->get('file') == null ? 'xls' : $request->get('file'),
                //    'download_format' => $request->get('file') == null ? 'xls' : $request->get('file'),
                //])->table($data->get()->toArray())->createExcelFile()->download();
            }

            // load relations
            if (count($this->indexLoad) > 0) {
                $data = $data->with($this->indexLoad);
            }

            // filters by
            if (!is_null($request->get('filters'))) {
                $data = (new QueryHelper())->deepFilter($data, (new RequestHelper())->getCollectFromJson($request['filters']));
            }

            // order by
            if (!is_null($request->get('order_by'))) {
                $data = (new QueryHelper())->orderBy($data, (new RequestHelper())->getCollectFromJson($request['order_by']));
            }

            // return response
            $response->setData(collect($data->paginate($pageSize)));
            $response->setMessage($this->getTrans('index', 'successful'));
            return SmartResponse::response($response);

        } catch (QueryException $exception) {

            // return response
            $response->setData(collect($exception->getMessage()));
            $response->setError($exception->getCode());
            $response->setMessage($this->getTrans('index', 'failed'));
            $response->setStatus(false);
            return SmartResponse::response($response);
        }
    }
807739
public function process(Request $request)
    {
        $this->validate($request->all(), $this->rules);

        if ($request->has('q')) {
            $this->searchQuery = $request->get('q');
        }
        if ($request->has('sort')) {
            foreach (explode(',', $request->get('sort')) as $sort) {
                $this->processOrderByParams($sort);
            }
        }
        $this->processPageParams($request);

        foreach ($this->parsers as $parser) {
            $parser->parse($request);
        }

        return $this;
    }
1210818
protected function authorize(Request $request)
    {
        $authorizer = $this->resolveAuthorizer($request);

        if ($authorizer) {
            $authorizer->authorize($this->getSubject());
        }
    }
213393
public function findByRequest(Request $request): ?PageInterface
    {
        if (null !== $route = $request->attributes->get('_route', null)) {
            return $this->findByRoute($route);
        }

        return null;
    }
1111589
public function run (Request $request)
    {
        try {

            // Define which method we need to handle
            $this->method = $request->getMethod();

            // Set request
            $this->request = $request;

            // Handle all routes
            $numHandled = 0;
            if (isset($this->routes[$this->method]))
                $numHandled = $this->handle($this->routes[$this->method], true);

            // If no route was handled, trigger the 404 (if any)
            if ($numHandled == 0) {
                if ($this->notFound) {
                    //call_user_func($this->notFound);
                    $this->handleMatch($this->notFound, array());
                } else {

                    $request = Response::error('Page not found.', Response::STATUS_NOTFOUND);
                    $request->output();
                }
            }

            // If it originally was a HEAD request, clean up after ourselves by emptying the output buffer
            if ($_SERVER['REQUEST_METHOD'] == 'HEAD') ob_end_clean();

        } catch (ResponseException $e) {
            $e->getResponse()->output();
        }
    }
723132
public function gridAction(Request $request)
    {
        $class = $request->get('class');
        if (!$class) {
            throw $this->createNotFoundException('No class passed in');
        }

        if ($rendererId = $request->get('renderer')) {
            if (!$this->container->has($rendererId)) {
                throw new \Exception("No renderer found with id $rendererId");
            }
            if (!($renderer = $this->container->has($rendererId)) instanceof AbstractRenderer) {
                throw new \Exception("Rennderer $rendererId must be instanace of Dtc\GridBundle\Grid\Renderer\AbstractRenderer");
            }
            if (!($view = $request->get('view'))) {
                throw new \Exception("No view parameter specified for renderer $rendererId");
            }
        } else {
            $rendererType = $request->get('type', 'table');
            $renderer = $this->get('dtc_grid.renderer.factory')->create($rendererType);
            $view = '@DtcGrid/Page/'.$rendererType.'.html.twig';
        }

        $gridSource = $this->get('dtc_grid.manager.source')->get($class);
        $renderer->bind($gridSource);

        return $this->render($view, $renderer->getParams());
    }
1071041
public function setRequest(RequestDescription $request)
    {
        $this->request = $request;
        $this->stack->setRequest($request);
    }