/** * Checks if the passed value is valid. * * @param AbstractProductProcessor $value The value that should be validated * @param Constraint $constraint The constraint for the validation * * @api */ public function validate($value, Constraint $constraint) { if (!$value instanceof AbstractProductProcessor) { return null; } if ($channel = $this->channelManager->getChannelByCode($value->getChannel())) { foreach ($channel->getCurrencies() as $currency) { if ($currency->getCode() === $value->getCurrency()) { return null; } } } $this->context->addViolationAt('currency', $constraint->message, ['currency']); }
/** * Checks if the passed value is valid. * * @param AbstractProductProcessor $value The value that should be validated * @param Constraint $constraint The constraint for the validation * * @api */ public function validate($value, Constraint $constraint) { if (!$value instanceof AbstractProductProcessor) { return null; } if ($channel = $this->channelManager->getChannelByCode($value->getChannel())) { foreach ($channel->getLocales() as $locale) { if ($locale->getCode() === $value->getDefaultLocale()) { return null; } } } $this->context->addViolationAt('defaultLocale', $constraint->message, ['defaultLocale']); }
/** * {@inheritdoc} */ public function getConfigurationFields() { return array_merge(parent::getConfigurationFields(), ['pimGrouped' => ['type' => 'choice', 'options' => ['choices' => $this->associationTypeManager->getAssociationTypeChoices(), 'help' => 'pim_prestashop_connector.export.pimGrouped.help', 'label' => 'pim_prestashop_connector.export.pimGrouped.label', 'attr' => ['class' => 'select2']]]]); }