/**
  * Add new instances of the MinimumOrder constraint to the constrain collection for each currency
  *
  * @param Collection $constraints
  *
  * @return Collection
  */
 public function addMinimumOrderConstraints(Collection $constraints)
 {
     foreach ($this->_currencies as $currency) {
         $constraint = new MinimumOrder($this->_translator);
         $constraint->setCurrency($currency);
         $constraints->add($constraint);
     }
     return $constraints;
 }
 /**
  * {@inheritDoc}
  */
 public function load(ConfigProxy $config)
 {
     $result = $this->_qbFactory->getQueryBuilder()->select($this->_columns)->from('refer_a_friend_reward_constraint')->where('reward_config_id = :id?i', ['id' => $config->getID()])->getQuery()->run();
     $constraints = new Collection();
     foreach ($result as $row) {
         $constraint = $this->_constraints->get($row->name);
         $constraint->setValue($row->value);
         $constraints->add($this->_constraints->get($row->name));
     }
     return $constraints;
 }
 /**
  * {@inheritDoc}
  */
 public function addConstraint(Constraint\ConstraintInterface $constraint)
 {
     if (!in_array($constraint->getName(), $this->_type->validConstraints())) {
         throw new \LogicException('Constraints of type `' . $constraint->getName() . '` cannot be set on rewards with a type of `' . $this->_type->getName() . '`');
     }
     if (null === $this->_constraints) {
         $this->_constraints = new Constraint\Collection();
     }
     $this->_constraints->add($constraint);
 }
 /**
  * Load and populate constraints with values, and add them to the Config
  *
  * @param Config $config
  *
  * @param array $formData
  */
 private function _addConstraints(Config $config, array $formData)
 {
     if (empty($formData['constraints'])) {
         return;
     }
     $constraintData = $formData['constraints'];
     if (!is_array($constraintData)) {
         $type = gettype($constraintData) === 'object' ? get_class($constraintData) : gettype($constraintData);
         throw new \LogicException('Constraint form data must be an array, ' . $type . ' given');
     }
     foreach ($constraintData as $name => $value) {
         if (null === $value) {
             continue;
         }
         $constraint = clone $this->_constraints->get($name);
         $constraint->setValue($value);
         $config->addConstraint($constraint);
     }
 }