setPage example



    #[Route(path: '/widgets/account/address-book', name: 'frontend.account.addressbook', options: ['seo' => true], defaults: ['XmlHttpRequest' => true, '_loginRequired' => true, '_loginRequiredAllowGuest' => true], methods: ['POST'])]     public function addressBook(Request $request, RequestDataBag $dataBag, SalesChannelContext $context, CustomerEntity $customer): Response
    {
        $viewData = new AddressEditorModalStruct();
        $params = [];

        try {
            $page = $this->addressListingPageLoader->load($request$context$customer);
            $this->hook(new AddressBookWidgetLoadedHook($page$context));
            $viewData->setPage($page);

            $this->handleChangeableAddresses($viewData$dataBag$context$customer);
            $this->handleAddressCreation($viewData$dataBag$context$customer);
            $this->handleAddressSelection($viewData$dataBag$context$customer);
            $this->handleCustomerVatIds($dataBag$context$customer);
        } catch (ConstraintViolationException $formViolations) {
            $params['formViolations'] = $formViolations;
            $params['postedData'] = $dataBag->get('address');
        } catch (\Exception) {
            $viewData->setSuccess(false);
            $viewData->setMessages([
                


            if (isset($payload['limit'])) {
                $this->addLimit($payload$criteria$searchException$maxLimit);
            }

            if ($criteria->getLimit() === null && $maxLimit !== null) {
                $criteria->setLimit($maxLimit);
            }

            if (isset($payload['page'])) {
                $this->setPage($payload$criteria$searchException);
            }
        }

        if (isset($payload['includes'])) {
            $criteria->setIncludes($payload['includes']);
        }

        if (isset($payload['filter'])) {
            $this->addFilter($definition$payload$criteria$searchException);
        }

        
$limit = $this->getLimit($request$context);

        $page = $this->getPage($request);

        $criteria->setOffset(($page - 1) * $limit);
        $criteria->setLimit($limit);
        $criteria->setTotalCountMode(Criteria::TOTAL_COUNT_MODE_EXACT);
    }

    public function process(Request $request, ProductListingResult $result, SalesChannelContext $context): void
    {
        $result->setPage($this->getPage($request));

        $result->setLimit($this->getLimit($request$context));
    }

    private function getLimit(Request $request, SalesChannelContext $context): int
    {
        $limit = $request->query->getInt('limit');

        if ($request->isMethod(Request::METHOD_POST)) {
            $limit = $request->request->getInt('limit', $limit);
        }

        
Home | Imprint | This part of the site doesn't use cookies.