Пример #1
0
 /**
  * modifiedを常に更新
  *
  * @param null $data 登録データ
  * @param bool $validate バリデートを実行するか
  * @param array $fieldList フィールド
  * @return mixed
  *
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function save($data = null, $validate = true, $fieldList = array())
 {
     // 保存前に modified フィールドをクリアする
     $this->set($data);
     if (isset($this->data[$this->alias]['modified'])) {
         unset($this->data[$this->alias]['modified']);
     }
     return parent::save($this->data, $validate, $fieldList);
 }
Пример #2
0
 /**
  * Called after each successful save operation.
  *
  * @param bool $created True if this save created a new record
  * @param array $options Options passed from Model::save().
  * @return void
  * @throws InternalErrorException
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave
  * @see Model::save()
  */
 public function afterSave($created, $options = array())
 {
     $this->loadModels(['CabinetFile' => 'Cabinet.CabinetFile']);
     //CabinetSetting登録
     if (isset($this->CabinetSetting->data['CabinetSetting'])) {
         $this->CabinetSetting->set($this->CabinetSetting->data['CabinetSetting']);
         $this->CabinetSetting->save(null, false);
     }
     // ルートフォルダがまだなければルートフォルダをつくる。あれば名前の同期
     if (!$this->CabinetFile->syncRootFolder($this->data)) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     parent::afterSave($created, $options);
 }