Esempio n. 1
0
 /**
  * Add an field to the model. If a field with the same name has already been added,
  * it will be replaced by the given field.
  *
  * @param Opus_Model_Field $field Field instance that gets appended to the models field collection.
  * @return Opus_Model_Abstract Provide fluent interface.
  */
 public function addField(Opus_Model_Field $field)
 {
     $fieldname = $field->getName();
     if (isset($fieldname, $this->_externalFields[$fieldname])) {
         $options = $this->_externalFields[$fieldname];
         // set ValueModelClass if a through option is given
         if (isset($options['model'])) {
             $field->setValueModelClass($options['model']);
         }
         // set LinkModelClass if a through option is given
         if (isset($options['through'])) {
             $field->setLinkModelClass($options['through']);
         }
         // set SortOrderField, if a "sort_field" option is given.
         if (isset($options['sort_field'])) {
             $field->setSortFieldName($options['sort_field']);
         }
     }
     return parent::addField($field);
 }