/** * {@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; }
/** * Load and populate constraints with values, and add them to the Config * * @param Config $config * * @param array $formData */ private function _addConstraints(Config $config, array $formData) { if (empty($formData['constraints'])) { return; } $constraintData = $formData['constraints']; if (!is_array($constraintData)) { $type = gettype($constraintData) === 'object' ? get_class($constraintData) : gettype($constraintData); throw new \LogicException('Constraint form data must be an array, ' . $type . ' given'); } foreach ($constraintData as $name => $value) { if (null === $value) { continue; } $constraint = clone $this->_constraints->get($name); $constraint->setValue($value); $config->addConstraint($constraint); } }