Permalink
Browse files

feature #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 #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
  • Loading branch information...
weaverryan committed Mar 27, 2014
2 parents b1e8f56 + d920148 commit 2d1ecd9622109a06fd9f72b0ef987d3fcd7801c1
Showing with 10 additions and 0 deletions.
  1. +10 −0 cookbook/doctrine/file_uploads.rst
@@ -410,6 +410,14 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
}
}
.. caution::
If changes to your entity are handled by a Doctrine event listener or event
subscriber, the ``preUpdate()`` callback must notify Doctrine about the changes
being done.
For full reference on preUpdate event restrictions, see `preUpdate`_ in the
Doctrine Events documentation.
The class now does everything you need: it generates a unique filename before
persisting, moves the file after persisting, and removes the file if the
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
order to remove the file. Before it's removed, you must store the file path
(since it depends on the id). Then, once the object has been fully removed
from the database, you can safely delete the file (in ``PostRemove``).
.. _`preUpdate`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preupdate

0 comments on commit 2d1ecd9

Please sign in to comment.