-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Update file_uploads.rst #3525
Update file_uploads.rst #3525
Conversation
Code examples do not apply to Doctrine EventSubscribers scenario, on preUpdate. Cheers.
I'm not sure if I understand the reasons for this change. Can you please explain them in more detail (maybe with an example)? |
I see, I agree. I'll update it asap.
|
The issue is that when you use a subscriber (or a listener), any changes made to your entity in The problem is that this isn't an even listener/subscriber. However, using an event listener is actually better, so I think we should find a place for the warning. But it needs to be much shorter. Do you think a short |
I agree that i'd be enough with a caution note, but the code example in
Besides updating the document's record, you need to call setNewValue() when $em = $args->getEntityManager(); Even more, in Doctrine Docs, they suggest using $args->setNewValue(); On Tue, Feb 4, 2014 at 1:23 AM, Ryan Weaver [email protected]:
|
Updated as per @RyanWeaver's suggestions.
For full reference on preUpdate event restrictions, see `preUpdate`_ in the in the Doctrine Events documentation. | ||
|
||
.. _`preUpdate`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preupdate | ||
|
There was a problem hiding this comment.
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 :)
I've just proposed a few changes, then I think we should merge this. More importantly, this entry is a real mess - I really dislike it. I think we should only show uploading happening via a Doctrine listener, and not via lifecycle events. In fact, even better would be an ORM-agnostic cookbook entry, where we show uploading being done properly in a service, with a little section on the end showing up you can trigger this automatically with a Doctrine listener (whereas in the agnostic part, we'd show the service function being called manually in a controller). OR, we should just link to VichUploaderBundle and make sure it's documentation is rock solid. VichUploaderBundle also helps solve the problem of how to create a link to the asset after uploading, a second piece of all of this that's very important and too hard currently. Thoughts? See #2346 :) |
I like the idea of a service, with kernel as a dependency for getting the project root dir without DIR. |
Hum.. |
$args->setNewValue('filename', $newFilename); | ||
} | ||
|
||
For full reference on preUpdate event restrictions, see `preUpdate`_ in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a full reference [...]
Great, thanks a lot for this Juan! Now, we'll need to get ionto a bigger improvement of the article :). |
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
Code examples do not apply to Doctrine EventSubscribers scenario, on preUpdate.
Cheers.