Skip to content

Commit

Permalink
minor #3419 doctrine file upload example uses dir -- caution added (c…
Browse files Browse the repository at this point in the history
…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 f2eaf9b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cookbook/doctrine/file_uploads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2eaf9b

Please sign in to comment.