Beispiel #1
0
 /**
  * Implements adder mechanism.
  *
  * @see Opus_Model_Abstract::_addFieldValue()
  */
 protected function _addFieldValue(Opus_Model_Field $field, $value)
 {
     // get Modelclass if model is linked
     $linkmodelclass = $field->getLinkModelClass();
     if (!is_null($linkmodelclass)) {
         // Check if $linkmodelclass is a known class name
         if (class_exists($linkmodelclass) === false) {
             throw new Opus_Model_Exception("Link model class '{$linkmodelclass}' does not exist.");
         }
         if (is_null($value)) {
             throw new InvalidArgumentException('Argument required when adding to a link field.');
         }
         if (!$value instanceof Opus_Model_Dependent_Link_Abstract) {
             $linkmodel = new $linkmodelclass();
             $linkmodel->setModel($value);
             $value = $linkmodel;
         }
     }
     $value = parent::_addFieldValue($field, $value);
     if ($value instanceof Opus_Model_Dependent_Abstract) {
         $value->setParentId($this->getId());
     }
     return $value;
 }