public function removeValue(EavValueCommon $value) { if (!isset($this->items[$value->getID()])) { return; } $this->removedItems[$value->getID()] = $this->items[$value->getID()]; unset($this->items[$value->getID()]); }
public function set(EavValueCommon $value) { // test whether the value belongs to the same field if ($value->getField()->get()->getID() != $this->getField()->get()->getID()) { $class = get_class($value->getField()->get()); throw new Exception('Cannot assign ' . $class . ':' . $value->getField()->get()->getID() . ' value to ' . $class . ':' . $this->getField()->get()->getID()); } if ($value !== $this->getValue()->get()) { $this->getValue()->set($value); } }
public static function restoreInstance(SpecField $field, $valueId, $value) { return parent::restoreInstance(__CLASS__, $field, $valueId, $value); }
public function mergeWith(EavValueCommon $specFieldValue) { if (!$specFieldValue->isExistingRecord()) { throw new ApplicationException(get_class($specFieldValue) . ' should be an existing record'); } if (get_class($this) != get_class($specFieldValue)) { throw new ApplicationException('Value classes do not match'); } if ($this === $specFieldValue) { return; } if (!in_array($specFieldValue, $this->mergedFields)) { $this->mergedFields[] = $specFieldValue; } }
/** * Adds a 'choice' value to this field * * @param SpecFieldValue $value */ public function addValue(EavValueCommon $value) { $value->getField()->set($this); $value->save(); }