/** * {@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); }
/** * Add query saving the constraint name and value, as well as the reward config ID, to the database transaction * * @param ConfigInterface $config * @param ConstraintInterface $constraint */ private function _addToTransaction(ConfigInterface $config, ConstraintInterface $constraint) { $this->_transaction->add("\n\t\t\tINSERT INTO\n\t\t\t\trefer_a_friend_reward_constraint\n\t\t\t\t(\n\t\t\t\t\treward_config_id,\n\t\t\t\t\t`name`,\n\t\t\t\t\t`value`\n\t\t\t\t)\n\t\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:rewardConfigID?i,\n\t\t\t\t\t:name?s,\n\t\t\t\t\t:value?s\n\t\t\t\t)\n\t\t", ['rewardConfigID' => $config->getID(), 'name' => $constraint->getName(), 'value' => $constraint->getValue()]); }