public function persist($model)
{
if (!$this->save($model)) {
if (isset($model->validationErrors) && $model->validationErrors) {
throw new SaveFailedException(get_class($model), $model->validationErrors);
}
throw new SaveFailedException(get_class($model));
}
if (!$this->isSaved($model)) {
$this->markSaved($model);
}
}