-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add docs for saveOrFail and deleteOrFail #4722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Using this method will throw an :php:exc:`Cake\\ORM\\Exception\\PersistenceFailedException` | ||
| if the application rules checks failed, the entity contains errors or the save was aborted by a callback. | ||
| Using this can be helpful when you performing complex database operations without human monitoring, | ||
| for example, inside a Shell task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add:
Do not use this for validation inside controller actions and where feedback to the user has to be given in forms.
etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One could use it there if they catch the exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but not without catching it then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Do not use' is pretty strongly worded when it can be used if you catch the resulting exceptions.
|
Edit: NVM thought it was a cakephp/app docker ;) |
|
@inoas you should have a look to the readme. |
| echo $e->getEntity(); | ||
| } | ||
|
|
||
| As this internally perfoms a :php:meth:`Cake\\ORM\\Table::delete()` call, all corresponding delete events will be triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/perfoms/performs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that post-merge.
As promised in cakephp/cakephp#10164, here are the docs for
Cake\ORM\Table::saveOrFail()andCake\ORM\Table::deleteOrFail().I hope I covered everything necessary.
On a site note, using the provided Dockerfile worked like a charme 👍