Beispiel #1
0
 /**
  * 
  * Returns the appropriate record object, honoring inheritance.
  * 
  * @param array $data The data to load into the record.
  * 
  * @return Solar_Sql_Model_Record A record object.
  * 
  */
 public function newRecord($data)
 {
     // the record to return, eventually
     $record = null;
     // look for an inheritance in relation to $data
     $inherit = null;
     if ($this->_inherit_col && !empty($data[$this->_inherit_col])) {
         // inheritance is available, and a value is set for the
         // inheritance column in the data
         $inherit = trim($data[$this->_inherit_col]);
     }
     // did we find an inheritance value?
     if ($inherit) {
         // try to find a model class based on inheritance, going up the
         // stack as needed. this checks for Current_Model_Type,
         // Parent_Model_Type, Grandparent_Model_Type, etc.
         //
         // blow up if we can't find it, since this is explicitly noted
         // as the inheritance class.
         $inherit_class = $this->_catalog->getClass($inherit);
         // if different from the current class, reset the model object.
         if ($inherit_class != $this->_class) {
             // use the inherited model class, it's different from the
             // current model. if it's not different, fall through, leaving
             // $record == null.  that will invoke the logic below.
             $model = $this->_catalog->getModelByClass($inherit_class);
             $record = $model->newRecord($data);
         }
     }
     // do we have a record yet?
     if (!$record) {
         // no, because an inheritance model was not specified, or was of
         // the same class as this class.
         $record = $this->_newRecord();
         $record->init($this, $data);
     }
     return $record;
 }
Beispiel #2
0
 /**
  * 
  * Loads $this->item with data from the current request POST data.
  * 
  * @return void
  * 
  */
 protected function _loadItem()
 {
     $model = $this->_model->getModel($this->model_name);
     $array_name = $model->array_name;
     $data = $this->_request->post($array_name, array());
     $cols = array();
     if (!empty($this->_form_cols[$this->_action])) {
         $cols = $this->_form_cols[$this->_action];
     }
     $this->item->load($data, $cols);
 }