/**
  * Loop through currencies and create a new instance of SetAmount for each one, with the currency applied
  *
  * @param Collection $rewardOptions
  *
  * @return Collection
  */
 public function addSetAmountRewardOptions(Collection $rewardOptions)
 {
     foreach ($this->_currencies as $currency) {
         $option = new SetAmount($this->_translator);
         $option->setCurrency($currency);
         $rewardOptions->add($option);
     }
     return $rewardOptions;
 }
 /**
  * {@inheritDoc}
  */
 public function load(ConfigProxy $config)
 {
     $result = $this->_qbFactory->getQueryBuilder()->select($this->_columns)->from('refer_a_friend_reward_option')->where('reward_config_id = :id?i', ['id' => $config->getID()])->getQuery()->run();
     $rewardOptions = new Collection();
     foreach ($result as $row) {
         $rewardOption = $this->_rewardOptions->get($row->name);
         $rewardOption->setValue($row->value);
         $rewardOptions->add($this->_rewardOptions->get($row->name));
     }
     return $rewardOptions;
 }
 /**
  * {@inheritDoc}
  */
 public function addRewardOption(RewardOption\RewardOptionInterface $rewardOption)
 {
     if (!in_array($rewardOption->getName(), $this->_type->validRewardOptions())) {
         throw new \LogicException('Reward options of type `' . $rewardOption->getName() . '` cannot be set on rewards with a type of `' . $this->_type->getName() . '`');
     }
     if (null === $this->_rewardOptions) {
         $this->_rewardOptions = new RewardOption\Collection();
     }
     $this->_rewardOptions->add($rewardOption);
 }
 /**
  * Load and populate reward options and add them to the Config
  *
  * @param Config $config
  *
  * @param array $formData
  */
 private function _addRewardOptions(Config $config, array $formData)
 {
     if (empty($formData['reward_options'])) {
         return;
     }
     $rewardOptionsData = $formData['reward_options'];
     if (!is_array($rewardOptionsData)) {
         $type = gettype($rewardOptionsData) === 'object' ? get_class($rewardOptionsData) : gettype($rewardOptionsData);
         throw new \LogicException('Reward option form data must be an array, ' . $type . ' given');
     }
     foreach ($rewardOptionsData as $name => $value) {
         if (null === $value) {
             continue;
         }
         $rewardOption = clone $this->_rewardOptions->get($name);
         $rewardOption->setValue($value);
         $config->addRewardOption($rewardOption);
     }
 }