/** * {@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; }
/** * 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); } }