Skip to content

Update file_uploads.rst #3525

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

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cookbook/doctrine/file_uploads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the URL link to the bottom of the document? That's where we keep them all :)

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.
Expand Down Expand Up @@ -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