/** * Adds calculator options to select * * @param ElementInterface|Select $select */ private function addCalculatorOptions(ElementInterface $select) { $collection = $this->getCalculators(); $collection->map(function (ShippingCalculatorInterface $calculator) use($select) { $select->addOptionToSelect($calculator->getAlias(), $calculator->getAlias()); }); }
public function addConfigurationFields(FormBuilderInterface $builder, ElementInterface $fieldset, DependencyInterface $dependency) { $fieldset->addChild($builder->getElement('text_field', ['name' => $this->getConfigurationKey('client_id'), 'label' => $this->trans('paypal.label.client_id'), 'dependencies' => [$dependency]])); $fieldset->addChild($builder->getElement('text_field', ['name' => $this->getConfigurationKey('client_secret'), 'label' => $this->trans('paypal.label.client_secret'), 'dependencies' => [$dependency]])); $fieldset->addChild($builder->getElement('select', ['name' => $this->getConfigurationKey('mode'), 'label' => $this->trans('paypal.label.mode'), 'options' => ['live' => 'live', 'sandbox' => 'sandbox'], 'dependencies' => [$dependency]])); $fieldset->addChild($builder->getElement('select', ['name' => $this->getConfigurationKey('type'), 'label' => $this->trans('paypal.label.type'), 'options' => ['paypal' => 'paypal', 'credit_card' => 'credit_card'], 'dependencies' => [$dependency]])); }
/** * Adds payment method options to select * * @param ElementInterface|RadioGroup $radioGroup */ private function addPaymentOptions(ElementInterface $radioGroup) { $order = $this->getOrderProvider()->getCurrentOrder(); $shippingMethod = $order->getShippingMethod(); if ($shippingMethod instanceof ShippingMethodInterface) { $collection = $shippingMethod->getPaymentMethods(); $collection->map(function (PaymentMethodInterface $paymentMethod) use($radioGroup) { $radioGroup->addOptionToSelect($paymentMethod->getId(), $paymentMethod->translate()->getName()); }); } }
public function addConfigurationFields(FormBuilderInterface $builder, ElementInterface $fieldset, DependencyInterface $dependency) { $fieldset->addChild($builder->getElement('text_field', ['name' => $this->getConfigurationKey('account_number'), 'label' => $this->trans('payment_method.bank_transfer.account_number'), 'dependencies' => [$dependency], 'default' => ''])); $fieldset->addChild($builder->getElement('text_field', ['name' => $this->getConfigurationKey('account_owner'), 'label' => $this->trans('payment_method.bank_transfer.account_owner'), 'dependencies' => [$dependency], 'default' => ''])); $fieldset->addChild($builder->getElement('text_field', ['name' => $this->getConfigurationKey('sort_number'), 'label' => $this->trans('payment_method.bank_transfer.sort_number'), 'dependencies' => [$dependency], 'default' => ''])); }
/** * @param ElementInterface $element * * @return string */ private function getPropertyPathAsIndex(ElementInterface $element) { return sprintf('[%s]', $element->getName()); }
public function addConfigurationFields(FormBuilderInterface $builder, ElementInterface $fieldset, DependencyInterface $dependency) { $fieldset->addChild($builder->getElement('tip', ['tip' => $this->trans('payment_method.cod.configuration'), 'dependencies' => [$dependency]])); }
/** * Transforms value if needed or directly changes model property * * @param ElementInterface $child */ protected function setModelValueFromElement(ElementInterface $child) { $propertyPath = $child->getPropertyPath(); if ($propertyPath instanceof PropertyPathInterface) { if ($this->propertyAccessor->isWritable($this->data, $propertyPath)) { if ($child->hasTransformer()) { $transformer = $child->getTransformer(); $transformer->reverseTransform($this->data, $propertyPath, $child->getValue()); } else { $this->propertyAccessor->setValue($this->data, $propertyPath, $child->getValue()); } } } }
/** * Returns attributes collection for element * * @param ElementInterface $element * * @return AttributeCollection */ protected function getAttributesCollection(ElementInterface $element) : AttributeCollection { $collection = new AttributeCollection(); $element->prepareAttributesCollection($collection); return $collection; }
/** * Returns child values * * @param ElementInterface $child * @param string $locale * * @return mixed|null */ protected function getChildValue(ElementInterface $child, $locale) { $accessor = $this->getPropertyAccessor(); $value = $child->getValue(); if (is_array($value)) { return $accessor->getValue($value, "[{$locale}]"); } return null; }
/** * Adds new element to collection * * @param ElementInterface $element */ public function add(ElementInterface $element) { $this->items[$element->getName()] = $element; }
/** * {@inheritdoc} */ public function formatElement(ElementInterface $element) { $collection = new AttributeCollection(); $element->prepareAttributesCollection($collection); return $this->formatAttributesCollection($collection); }
/** * Sets errors on element * * @param array $messages * @param ElementInterface $element */ protected function mapMessagesToElement(array $messages, ElementInterface $element) { if ($element->hasPropertyPath()) { $propertyPathParts = explode('.', $element->getPropertyPath(false)); $propertyPath = $this->buildPath($propertyPathParts); if ($this->propertyAccessor->isReadable($messages, $propertyPath)) { $errors = $this->propertyAccessor->getValue($messages, $propertyPath); $element->setError($errors); } } $children = $element->getChildren(); if ($children->count()) { $this->mapMessagesToElementCollection($messages, $children); } }