Permalink
Browse files

minor #3419 doctrine file upload example uses dir -- caution added (c…

…ordoval)

This PR was merged into the 2.3 branch.

Discussion
----------

doctrine file upload example uses dir -- caution added

| Q             | A                   |
| ---           | ---                 |
| Doc fix?      | yes                 |
| New docs?     | no                  |
| Applies to    | 2.3+                |
| Fixed tickets | #3363               |
| License       | CC-ASA 3.0 Unported |

 Sent using [Gush](https://github.com/cordoval/gush)

Commits
-------

1620ed8 3363-doctrine-file-upload-example-uses-dir
  • Loading branch information...
weaverryan committed Jan 21, 2014
2 parents 72b53ad + 1620ed8 commit f2eaf9bbc5d3a73c83ef6e4ce1830bd3e277dcc0
Showing with 9 additions and 0 deletions.
  1. +9 −0 cookbook/doctrine/file_uploads.rst
@@ -300,6 +300,15 @@ object, which is what's returned after a ``file`` field is submitted::
Using Lifecycle Callbacks
-------------------------
.. caution::
Using lifecycle callbacks is a limited technique that has some drawbacks.
If you want to remove the hard coded ``__DIR__`` reference inside
the ``Document::getUploadRootDir()`` method, the best way is to start
using explicit :doc:`doctrine listeners </cookbook/doctrine/event_listeners_subscribers>`
where you will be able to inject kernel parameters such as
``kernel.root_dir`` to be able to build absolute paths.
Even if this implementation works, it suffers from a major flaw: What if there
is a problem when the entity is persisted? The file would have already moved
to its final location even though the entity's ``path`` property didn't

0 comments on commit f2eaf9b

Please sign in to comment.