Exemple #1
0
 /**
  * Sets Entity field, or an extension field, to a given value
  *
  * @see Doctrine_Record
  */
 public function set($fieldName, $value, $load = true)
 {
     //try Entity first, unless it's the 'name' field
     $entityFields = array_merge(array_keys($this->_data), array_keys($this->getTable()->getRelations()));
     if (in_array($fieldName, $entityFields) && $fieldName != 'name') {
         return parent::set($fieldName, $value, $load);
     }
     //then try the extensions
     $fields = $this->getExtensionFields(true);
     if (array_key_exists($fieldName, $fields)) {
         foreach ($fields[$fieldName] as $extension) {
             $this->_extensionObjects[$extension]->set($fieldName, $value, $load);
         }
     } else {
         //the field doesn't exist: do what the parent would do
         parent::set($fieldName, $value, $load);
     }
     return $this;
 }