Skip to content

Commit f2eaf9b

Browse files
committed
minor symfony#3419 doctrine file upload example uses dir -- caution added (cordoval)
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 | symfony#3363 | | License | CC-ASA 3.0 Unported | Sent using [Gush](https://github.com/cordoval/gush) Commits ------- 1620ed8 3363-doctrine-file-upload-example-uses-dir
2 parents 72b53ad + 1620ed8 commit f2eaf9b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cookbook/doctrine/file_uploads.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ object, which is what's returned after a ``file`` field is submitted::
300300
Using Lifecycle Callbacks
301301
-------------------------
302302

303+
.. caution::
304+
305+
Using lifecycle callbacks is a limited technique that has some drawbacks.
306+
If you want to remove the hard coded ``__DIR__`` reference inside
307+
the ``Document::getUploadRootDir()`` method, the best way is to start
308+
using explicit :doc:`doctrine listeners </cookbook/doctrine/event_listeners_subscribers>`
309+
where you will be able to inject kernel parameters such as
310+
``kernel.root_dir`` to be able to build absolute paths.
311+
303312
Even if this implementation works, it suffers from a major flaw: What if there
304313
is a problem when the entity is persisted? The file would have already moved
305314
to its final location even though the entity's ``path`` property didn't

0 commit comments

Comments
 (0)