Skip to content

Commit 2030b28

Browse files
juanmfweaverryan
authored andcommitted
Update file_uploads.rst
Code examples do not apply to Doctrine EventSubscribers scenario, on preUpdate. Cheers.
1 parent b1e8f56 commit 2030b28

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cookbook/doctrine/file_uploads.rst

+6
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
371371
// do whatever you want to generate a unique name
372372
$filename = sha1(uniqid(mt_rand(), true));
373373
$this->path = $filename.'.'.$this->getFile()->guessExtension();
374+
// Note: is you choose to use EvensubScribers, this change has no effect un database Update
375+
// the 'initial' value set in {@link self::setFile()} is used instead. As this occurs
376+
// inside EntityManager#flush() and changeSets are not tracked.
377+
// use \Doctrine\Common\Persistence\Event\PreUpdateEventArgs $args as the handler fn param and
378+
// $args->setNewValue('path', $filename);
379+
// source: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preupdate
374380
}
375381
}
376382

0 commit comments

Comments
 (0)