/**
  * 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;
 }
コード例 #2
0
 /**
  * {@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);
 }
コード例 #3
0
 /**
  * {@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;
 }