setPost example



        $voteConfirmed = false;

        $hash = $this->Request()->getParam('sConfirmation');
        if ($hash) {
            $getVote = $this->container->get('db')->fetchRow(
                'SELECT * FROM s_core_optin WHERE hash = ?',
                [$hash]
            );
            if (!empty($getVote['data'])) {
                $this->container->get('front')->ensureRequest()->setPost(unserialize($getVote['data']['allowed_classes' => false]));
                $voteConfirmed = true;
                $this->container->get('db')->query('DELETE FROM s_core_optin WHERE hash = ?', [$hash]);
            }
        }

        if (empty($this->container->get('front')->ensureRequest()->getPost('sVoteSummary'))) {
            $sErrorFlag['sVoteSummary'] = true;
        }

        if (!$voteConfirmed) {
            $captchaValidator = $this->container->get('shopware.captcha.validator');

            
&& \is_string($contentType)
            && str_starts_with($contentType, 'application/json')
            && \is_string($input)
        ) {
            if ($input !== '') {
                $input = Zend_Json::decode($input);
            } else {
                $input = null;
            }

            if ($this->padding !== null && isset($input[0])) {
                $request->setPost($this->padding, $input);
            } else {
                foreach ((array) $input as $key => $value) {
                    if ($value !== null) {
                        $request->setPost($key$value);
                    }
                }
            }
        }

        // Parse the json Params         if (\count($this->parseParams)) {
            
// If any basic info is missing, return error messages         if (!empty($sErrorFlag) || !empty($sErrorMessages)) {
            $this->View()->assign('sErrorFlag', $sErrorFlag);
            $this->View()->assign('sErrorMessages', $sErrorMessages);

            $this->forward('shippingPayment');

            return;
        }

        // Validate the payment details         $this->front->ensureRequest()->setPost('sPayment', $payment);
        $checkData = $this->admin->sValidateStep3();

        // Problem with the payment details, return error         if (!empty($checkData['checkPayment']['sErrorMessages']) || empty($checkData['sProcessed'])) {
            $this->View()->assign('sErrorFlag', $checkData['checkPayment']['sErrorFlag']);
            $this->View()->assign('sErrorMessages', $checkData['checkPayment']['sErrorMessages']);

            $this->forward('shippingPayment');

            return;
        }

        
/** * @param mixed $offset the offset to assign the value to * @param mixed $value the value to set * * @return void * * @deprecated - Native return and parameter type will be added with Shopware 5.8 */
    #[ReturnTypeWillChange]     public function offsetSet($offset$value)
    {
        $this->request->setPost($offset$value);
    }

    /** * @param mixed $offset the offset to unset * * @throws Exception * * @return void * * @deprecated - Native return and parameter type will be added with Shopware 5.8 */
    


    /** * Create new user * * POST /api/users */
    public function postAction(): void
    {
        if (!$this->Request()->getParam('password')) {
            $passwordPlain = Random::generatePassword();
            $this->Request()->setPost('password', $passwordPlain);
        }

        if ($this->Request()->getParam('apiKey') && \strlen($this->Request()->getParam('apiKey')) < 40) {
            throw new CustomValidationException('apiKey is too short. The minimal length is 40.');
        }

        $user = $this->resource->create($this->Request()->getPost());

        $location = $this->apiBaseUrl . 'users/' . $user->getId();
        $data = [
            'id' => $user->getId(),
            
$session->offsetSet('sRegisterFinished', true);
        $session->offsetSet('sCountry', $shippingCountry->getId());
        $session->offsetSet('sArea', $shippingCountry->getArea() !== null ? $shippingCountry->getArea()->getId() : 0);

        if ($customer->getAccountMode() === Customer::ACCOUNT_MODE_FAST_LOGIN) {
            $session->offsetSet('sOneTimeAccount', true);
        }
    }

    private function loginCustomer(Customer $customer): void
    {
        $this->front->Request()->setPost('email', $customer->getEmail());
        $this->front->Request()->setPost('passwordMD5', $customer->getPassword());
        Shopware()->Modules()->Admin()->sLogin(true);
    }

    /** * Redirects after registration to the corresponding controllers and actions */
    private function redirectCustomer(array $params = []): void
    {
        $location = [
            'controller' => $this->Request()->getParam('sTarget', 'account'),
            
$this->request->replace([]);

            return $this;
        }

        if (($value === null) && !\is_array($spec)) {
            throw new RuntimeException('Invalid value passed to setPost(); must be either array of values or key/value pair');
        }

        if (($value === null) && \is_array($spec)) {
            foreach ($spec as $key => $specValue) {
                $this->setPost($key$specValue);
            }

            return $this;
        }

        if (!\is_array($spec)) {
            $_POST[(string) $spec] = $value;
            $this->request->set((string) $spec$value);
        }

        return $this;
    }

    public function savePaymentAction()
    {
        if ($this->Request()->isPost()) {
            $sourceIsCheckoutConfirm = $this->Request()->getParam('sourceCheckoutConfirm');
            $values = $this->Request()->getPost('register');
            $frontRequest = $this->front->Request();
            if ($frontRequest === null) {
                throw new RuntimeException('Front controller has no request set');
            }
            $frontRequest->setPost('sPayment', $values['payment']);
            $checkData = $this->admin->sValidateStep3();

            if (!empty($checkData['checkPayment']['sErrorMessages']) || empty($checkData['sProcessed'])) {
                if (empty($sourceIsCheckoutConfirm)) {
                    $this->View()->assign('sErrorFlag', $checkData['checkPayment']['sErrorFlag']);
                    $this->View()->assign('sErrorMessages', $checkData['checkPayment']['sErrorMessages']);
                }

                $this->forward('payment');

                return;
            }


    public function preDispatch()
    {
        parent::preDispatch();

        // We still support the old behavior         $request = $this->Request();
        $localeId = $request->getPost('localeId');

        if ($localeId !== null) {
            $request->setPost('shopId', $localeId);
            $request->setPost('localeId', null);
        }
    }

    /** * Get list of translations * * GET /api/translations/ */
    public function indexAction()
    {
        
Home | Imprint | This part of the site doesn't use cookies.