Skip to content

Commit 2d1ecd9

Browse files
committed
feature symfony#3525 Update file_uploads.rst (juanmf)
This PR was submitted for the 2.4 branch but it was merged into the 2.3 branch instead (closes symfony#3525). Discussion ---------- Update file_uploads.rst Code examples do not apply to Doctrine EventSubscribers scenario, on preUpdate. Cheers. Commits ------- 075612a Going back to the ``Caution`` alternative. 2e21a0b Rewording Caution paragraph at line 413 3b0c75d Update file_uploads.rst 25539c5 Update file_uploads.rst
2 parents b1e8f56 + d920148 commit 2d1ecd9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cookbook/doctrine/file_uploads.rst

+10
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,14 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
410410
}
411411
}
412412

413+
.. caution::
414+
415+
If changes to your entity are handled by a Doctrine event listener or event
416+
subscriber, the ``preUpdate()`` callback must notify Doctrine about the changes
417+
being done.
418+
For full reference on preUpdate event restrictions, see `preUpdate`_ in the
419+
Doctrine Events documentation.
420+
413421
The class now does everything you need: it generates a unique filename before
414422
persisting, moves the file after persisting, and removes the file if the
415423
entity is ever deleted.
@@ -546,3 +554,5 @@ You'll notice in this case that you need to do a little bit more work in
546554
order to remove the file. Before it's removed, you must store the file path
547555
(since it depends on the id). Then, once the object has been fully removed
548556
from the database, you can safely delete the file (in ``PostRemove``).
557+
558+
.. _`preUpdate`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preupdate

0 commit comments

Comments
 (0)