public function buildForm(Form\FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', ['label' => 'ms.commerce.product.create.name.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.name.placeholder')], 'constraints' => [new Constraints\NotBlank()]])->add('brand', 'text', ['label' => 'ms.commerce.product.create.brand.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.brand.placeholder')]])->add('category', 'text', ['label' => 'ms.commerce.product.create.category.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.category.placeholder')], 'constraints' => [new Constraints\NotBlank()]])->add('units', 'collection', ['type' => 'product_unit', 'allow_add' => true, 'prototype_name' => '__unit__', 'label' => false, 'constraints' => [new Constraints\NotBlank()]]); $prices = $builder->create('prices', 'price_form', ['constraints' => [new Constraints\NotBlank()]]); $builder->add($prices)->add('description', 'textarea', ['label' => 'ms.commerce.product.create.description.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.create.description.placeholder')]])->add('type', 'choice', ['label' => 'ms.commerce.product.attributes.type.label', 'choices' => $this->_productTypes->getList(), 'constraints' => [new Constraints\NotBlank()]]); return $this; }
/** * @param DB\QueryBuilderFactory $builderFactory * @param UrlGenerator $routingGenerator * @param FilterCollection $filters * @param EventDispatcher $dispatcher * @param Translator $translator */ public function __construct(DB\QueryBuilderFactory $builderFactory, UrlGenerator $routingGenerator, FilterCollection $filters, EventDispatcher $dispatcher, Translator $translator) { parent::__construct($builderFactory, $routingGenerator); $this->_setName('mailing_subscribers'); $this->_setDisplayName('Subscribers'); $this->_setReportGroup('Mailing'); $this->_charts = [new TableChart()]; $this->_filters = $filters; $this->_dispatcher = $dispatcher; $this->_translator = $translator; $this->_description = $this->_translator->trans('ms.mailing.report.subscribers.description'); }
/** * {@inheritDoc} */ public function buildForm(Form\FormBuilderInterface $builder, array $options) { $builder->add(self::ID, 'hidden'); $builder->add(self::NAME, 'text', ['label' => 'ms.discount.bundle.name.label', 'contextual_help' => 'ms.discount.bundle.name.help', 'constraints' => [new Constraints\NotBlank()]]); $builder->add(self::START, 'date', ['label' => 'ms.discount.bundle.start.label', 'contextual_help' => 'ms.discount.bundle.start.help']); $builder->add(self::END, 'date', ['label' => 'ms.discount.bundle.end.label', 'contextual_help' => 'ms.discount.bundle.end.help']); foreach ($this->_currencies as $currency) { $builder->add(self::PRICE_PREFIX . $currency, 'money', ['label' => $this->_translator->trans('ms.discount.bundle.price.label', ['%currencyID%' => $currency]), 'contextual_help' => $this->_translator->trans('ms.discount.bundle.price.help', ['%currencyID%' => $currency]), 'constraints' => [new Constraints\NotBlank()], 'currency' => $currency]); } $builder->add(self::IMAGE, 'ms_file', ['label' => 'ms.discount.bundle.image.label', 'contextual_help' => 'ms.discount.bundle.image.help', 'choices' => $this->_getImageChoices()]); $builder->add(self::CODES, 'checkbox', ['label' => 'ms.discount.bundle.allow_codes.label', 'contextual_help' => 'ms.discount.bundle.allow_codes.help']); $builder->add(self::PRODUCT, 'collection', ['type' => $this->_productForm, 'label' => 'ms.discount.bundle.product.label', 'contextual_help' => 'ms.discount.bundle.product.help', 'allow_add' => true, 'allow_delete' => true]); $builder->addModelTransformer(new DataTransformer\BundleTransformer($this->_factory)); }
/** * Loop through gateways and create submit buttons to give to the form. The translator will attempt * to find a string determined by the gateway for that * * @param Form\FormBuilderInterface $builder */ private function _addSubmitButtons(Form\FormBuilderInterface $builder) { foreach ($this->_gateways as $gateway) { if (count($this->_gateways) === 1) { $label = 'ms.ecom.checkout.payment.continue'; } else { $transString = 'ms.' . $gateway->getName() . '.payment.button'; $label = $this->_translator->trans($transString); if ($label === $transString) { $label = $this->_translator->trans('ms.ecom.checkout.payment.gateway', ['%gateway%' => $this->_convertName($gateway->getName())]); } } $builder->add($gateway->getName(), 'submit', ['label' => $label]); } }
private function _validateNoRestrictedBundles() { foreach ($this->getOrder()->discounts as $discount) { if ($discount->getType() === Bundle\OrderDiscountFactory::NO_CODES) { throw new OrderValidityException($this->_trans->trans('ms.discount.discount.add.error.bundle_no_codes', ['%bundleName%' => $discount->name])); } } }
/** * Add extra details to the end of the name to help users better identify them * * @return string */ private function _getNameSuffix() { $suffix = $this->getName() ? '(' : ''; $suffix .= $this->_translator->trans($this->getType()->getDisplayName()); if (null !== $this->_createdAt) { $suffix .= ', ' . $this->_createdAt->format(self::DATE_FORMAT); } $suffix .= $this->getName() ? ')' : ''; return $suffix; }
/** * Generate columns to allow for variants */ private function _setVariantColumns() { for ($i = 1; $i <= HeadingKeys::NUM_VARIANTS; $i++) { $varName = HeadingKeys::VAR_NAME_PREFIX . $i; $varVal = HeadingKeys::VAR_VAL_PREFIX . $i; $transName = $this->_trans->trans(self::TRANS_PREFIX . HeadingKeys::VAR_NAME_PREFIX) . ' ' . $i; $transVal = $this->_trans->trans(self::TRANS_PREFIX . HeadingKeys::VAR_VAL_PREFIX) . ' ' . $i; $this->_variantColumns[$varName] = $transName; $this->_variantColumns[$varVal] = $transVal; isset($this->_dependantCols[$transName]) || ($this->_dependantCols[$transName] = []); if (!in_array($transVal, $this->_dependantCols[$transName])) { $this->_dependantCols[$transName][] = $transVal; } isset($this->_dependantCols[$transVal]) || ($this->_dependantCols[$transVal] = []); if (!in_array($transName, $this->_dependantCols[$transVal])) { $this->_dependantCols[$transVal][] = $transName; } } }
/** * Translates the description here and appends the currency ID * * {@inheritDoc} */ public function getDescription() { return $this->_translator->trans('ms.discount_reward.reward.constraints.minimum_order.description') . ' (' . $this->_currency . ')'; }
public function buildForm(Form\FormBuilderInterface $builder, array $options) { $builder->add('terms', 'search', ['label' => 'ms.commerce.product.search.label', 'attr' => array('placeholder' => $this->_trans->trans('ms.commerce.product.search.placeholder') . '…')]); }
public function getFieldOptions() { $defaults = ['choices' => $this->_getChoices(), 'allowed_types' => $this->_allowedTypes ?: false, 'empty_value' => $this->_translator->trans('ms.file_manager.select.default')]; return array_merge($defaults, parent::getFieldOptions()); }
/** * Translates the description here and appends the currency ID * * {@inheritDoc} */ public function getDescription() { return $this->_translator->trans('ms.discount_reward.reward.options.set_amount.description') . ' (' . $this->_currency . ')'; }
/** * Translate a string and throw an exception with that string as the message. * * @param $message * @param array $params * @throws Exception\BundleValidationException Will always throw a validation exception */ private function _error($message, $params = []) { throw new Exception\BundleValidationException($this->_translator->trans($message, $params)); }
public function buildForm(Form\FormBuilderInterface $builder, array $options) { $builder->add('sku', 'text', ['label' => 'ms.commerce.product.units.sku.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.units.sku.placeholder')]])->add('stock', 'number', ['label' => 'ms.commerce.product.stock.set.label', 'attr' => ['placeholder' => $this->_trans->trans('ms.commerce.product.stock.set.placeholder')]]); $builder->add('variants', 'collection', ['type' => 'product_variant', 'allow_add' => true, 'prototype_name' => '__variant__', 'label' => false]); return $this; }