Skip to content

Commit d920148

Browse files
juanmfweaverryan
authored andcommitted
Going back to the Caution alternative.
1 parent 8d00f1a commit d920148

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

cookbook/doctrine/file_uploads.rst

+6-15
Original file line numberDiff line numberDiff line change
@@ -410,22 +410,13 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
410410
}
411411
}
412412

413-
When using a Doctrine event listener or subscriber, when you make changes
414-
to your entity, the preUpdate() callback must have an extra line of code to
415-
tell Doctrine about the change::
416-
417-
public function preUpdate(PreUpdateEventArgs $args)
418-
{
419-
$entity = $args->getEntity();
420-
// do all the file uploading logic
421-
// ...
422-
$entity->setFilename($newFilename);
423-
$args->setNewValue('filename', $newFilename);
424-
}
425-
426-
For full reference on preUpdate event restrictions, see `preUpdate`_ in the
427-
Doctrine Events documentation.
413+
.. caution::
428414

415+
If changes to your entity are handled by a Doctrine event listener or event
416+
subscriber, the ``preUpdate()`` callback must notify Doctrine about the changes
417+
being done.
418+
For full reference on preUpdate event restrictions, see `preUpdate`_ in the
419+
Doctrine Events documentation.
429420

430421
The class now does everything you need: it generates a unique filename before
431422
persisting, moves the file after persisting, and removes the file if the

0 commit comments

Comments
 (0)