setMessages example

$this->hydrateFromCustomer($dataBag$customer),
                $context,
                false
            );

            $newsletterAccountPagelet->setSuccess(true);
            if ($newsletterAccountPagelet->isNewsletterDoi()) {
                $text = $this->translator->trans('newsletter.subscriptionPersistedSuccess');
            } else {
                $text = $this->translator->trans('newsletter.subscriptionConfirmationSuccess');
            }
            $newsletterAccountPagelet->setMessages(
                [
                    [
                        'type' => 'success',
                        'text' => $text,
                    ],
                ]
            );
        } catch (\Exception) {
            $newsletterAccountPagelet->setSuccess(false);
            $newsletterAccountPagelet->setMessages(
                [
                    [


    /** * Set options for the email validator * * @param array $options * @return Zend_Validate_EmailAddress fluid interface */
    public function setOptions(array $options = array())
    {
        if (array_key_exists('messages', $options)) {
            $this->setMessages($options['messages']);
        }

        if (array_key_exists('hostname', $options)) {
            if (array_key_exists('allow', $options)) {
                $this->setHostnameValidator($options['hostname']$options['allow']);
            } else {
                $this->setHostnameValidator($options['hostname']);
            }
        } elseif ($this->_options['hostname'] == null) {
            $this->setHostnameValidator();
        }

        
$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([
                'type' => self::DANGER,
                'text' => $this->trans('error.message-default'),
            ]);
        }

        if ($request->get('redirectTo') || $request->get('forwardTo')) {
            return $this->createActionResponse($request);
        }
        $params = array_merge($params$viewData->getVars());

        $response = $this->renderStorefront(
            
if (!isset($validatorRule[self::VALIDATOR_CHAIN])) {
                $validatorRule[self::VALIDATOR_CHAIN] = new Zend_Validate();

                foreach ($validatorList as $key => $validator) {
                    if (is_string($validator) || is_array($validator)) {
                        $validator = $this->_getValidator($validator);
                    }

                    if (isset($validatorRule[self::MESSAGES][$key])) {
                        $value = $validatorRule[self::MESSAGES][$key];
                        if (is_array($value)) {
                            $validator->setMessages($value);
                        } else {
                            $validator->setMessage($value);
                        }

                        if ($validator instanceof Zend_Validate_NotEmpty) {
                            /** we are changing the defaults here, this is alright if all subsequent validators are also a not empty * validator, but it goes wrong if one of them is not AND is required!!! * that is why we restore the default value at the end of this loop */
                            if (is_array($value)) {
                                $temp = $value; // keep the original value
Home | Imprint | This part of the site doesn't use cookies.