/** * Any changes to the model must be re-cached. * @see RedBeanModel::save() */ public function save($runValidation = true, array $attributeNames = null) { $saved = parent::save($runValidation, $attributeNames); if ($saved) { GeneralCache::cacheEntry('CustomFieldData' . $this->name, $this); } return $saved; }
protected function processCreateAction() { if ($this->resolveCreateModel($this->triggeredModel, $this->action->relation) && $this->canSaveTriggeredModel) { $saved = $this->triggeredModel->save(); if (!$saved) { throw new FailedToSaveModelException(); } } }
public static function processAfterCopy(RedBeanModel $model, RedBeanModel $copyToModel) { foreach ($model->tasks as $task) { $copyToTask = new Task(); TaskActivityCopyModelUtil::copy($task, $copyToTask); $copyToTask->status = Task::STATUS_NEW; $copyToModel->tasks->add($copyToTask); } $copyToModel->save(); }
public function unrestrictedSave($runValidation = true, array $attributeNames = null) { return parent::save($runValidation, $attributeNames); }
public static function saveAndReloadModel(RedBeanModel $model) { $saved = $model->save(); if (!$saved) { throw new FailedToSaveModelException(); } $modelId = $model->id; $modelClassName = get_class($model); $model->forget(); unset($model); return $modelClassName::getById($modelId); }
/** * Override to resetCache after a currency is saved. * (non-PHPdoc) * @see RedBeanModel::save() */ public function save($runValidation = true, array $attributeNames = null) { $saved = parent::save($runValidation, $attributeNames); self::resetCaches(); return $saved; }
protected static function refreshModel(RedBeanModel &$model) { assert('$model->id > 0'); // this is just a fail safe. We don't want to lose any unsaved changes. // ideally $model should be saved by this point anyway, but regardless: if ($model->isModified() && !$model->save()) { throw new FailedToSaveModelException(); } $modelId = $model->id; $modelClass = get_class($model); $model->forgetAll(); $model = $modelClass::getById($modelId); }