/** * {@inheritDoc} */ public function load(ConfigProxy $config) { $result = $this->_qbFactory->getQueryBuilder()->select($this->_columns)->from('refer_a_friend_reward_trigger')->where('reward_config_id = :id?i', ['id' => $config->getID()])->getQuery()->run(); $triggers = new Collection(); foreach ($result as $row) { $triggers->add($this->_triggers->get($row->name)); } return $triggers; }
/** * Load trigger and add it to the Config * * @param Config $config * * @param array $formData */ private function _addTriggers(Config $config, array $formData) { if (empty($formData['triggers']) || $formData['triggers'] === RewardConfig::NONE) { return; } $trigger = $this->_triggers->get($formData['triggers']); $config->addTrigger($trigger); }
/** * {@inheritDoc} */ public function addTrigger(Trigger\TriggerInterface $trigger) { if (!in_array($trigger->getName(), $this->_type->validTriggers())) { throw new \LogicException('Triggers of type `' . $trigger->getName() . '` cannot be set on rewards with a type of `' . $this->_type->getName() . '`'); } if (null === $this->_triggers) { $this->_triggers = new Trigger\Collection(); } $this->_triggers->add($trigger); }