Example #1
0
 /**
  * Set valid values for object props before save
  *
  * @return	void
  **/
 protected function _validateFields()
 {
     parent::_validateFields();
     $this->default = !is_null($this->default) ? 1 : 0;
     if (!$this->visibility_condition) {
         $this->visibility_condition = NULL;
     }
 }
Example #2
0
 /**
  * Set valid values for object props before save
  *
  * @return	void
  **/
 protected function _validateFields()
 {
     parent::_validateFields();
     if (!$this->can_detail) {
         $this->can_detail = NULL;
     }
     if (!$this->visibility_condition) {
         $this->visibility_condition = NULL;
     }
     //$this->can_detail = (!is_null($this->can_detail) ? 1 : 0;
 }
Example #3
0
 /**
  * Saves this object
  *
  * @return	bool
  **/
 public function save()
 {
     if (!$this->_existsInDb()) {
         $this->id = mb_strtolower($this->id, mb_detect_encoding($this->id));
     }
     return parent::save();
 }
Example #4
0
 /**
  * Creates (not save) Anketa Entity object
  *
  * @param 		string						storage_name
  * @param 		array						post
  * @param 		RM_Anketa_Entity|NULL		obEntity
  * @return		RM_Anketa_Entity
  **/
 public function createEntity($storage_name, $post = array(), RM_Anketa_Entity $obEntity = NULL)
 {
     // выберем из входных данных самое необходимое (через массив fields) :)
     $data = $this->_filterIncomingData($storage_name, $post);
     // запомним id родительского объекта obEntity, если таковой требуется для данного объекта
     $parent_type = @$this->parent_type($storage_name);
     if ($parent_type) {
         if ($obEntity->type() != $parent_type) {
             throw new RM_Base_Exception_BadUsage(__METHOD__ . "(): inappropriate parent entity type. `" . $parent_type . "` expected, `" . $obEntity->type() . "` given.");
         }
         $data[$parent_type . '_id'] = $obEntity->id();
     }
     /*
     		if ($storage_name == 'subanswer')
     			$obEntity->save();
     */
     // создадим и вернем объект (без сохраннения в бд!)
     return $this->_storages[$storage_name]->createObject($data);
 }