In the previous video we covered how to handle multiple file uploads. In this video we expand on what we have already learned about file uploads, and we incrementally improve the system, covering in more detail the topics discussed in the latter part of the previous video.
We're going to make use of Doctrine's Lifecycle Callbacks as part of this change, listening on
PostUpdate. The key thing to be aware of here is that the Update callbacks are only triggered if something on the entity changes. I know this sounds obvious, but it can be quite confusing when you're engrossed in your code, have a deadline to meet, and there's suddenly some seemingly inexplicable bug that seems to defy your expectation.
One trick to get round this is to ensure that something always changes on your entity - the easiest being a timestamp (think Created At / Updated At), so even if nothing else changes, you can update the
UpdatedAt property and know your
PostUpdate callbacks will be triggered.
I covered the majority of the changes in the previous video and the associated show notes, so this video is really a visual walkthrough of the remaining process.
If you have found this video helpful, please consider sharing. I really appreciate it.
|1||Keeping it simple||04:01|
|2||Uploading a collection of things to a FOSRESTBundle API||11:24|
|3||Collections of UploadedFile||10:16|
|4||Collections of UploadedFile - Part 2 : Towards A Better Implementation||09:46|