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()]);
 }
Example #2
0
 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);
     }
 }
Example #3
0
 public static function restoreInstance(SpecField $field, $valueId, $value)
 {
     return parent::restoreInstance(__CLASS__, $field, $valueId, $value);
 }
Example #4
0
 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;
     }
 }
Example #5
0
 /**
  * Adds a 'choice' value to this field
  *
  * @param SpecFieldValue $value
  */
 public function addValue(EavValueCommon $value)
 {
     $value->getField()->set($this);
     $value->save();
 }