From a023ef8745818821986d0bfdefcd6152c686bd10 Mon Sep 17 00:00:00 2001 From: Niels Nijens Date: Wed, 18 May 2016 16:50:34 +0200 Subject: [PATCH] Fix preparation of file uploads for new objects in ObjectUploadSubscriber --- EventListener/ObjectUploadSubscriber.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/EventListener/ObjectUploadSubscriber.php b/EventListener/ObjectUploadSubscriber.php index 5352608..9bc673c 100644 --- a/EventListener/ObjectUploadSubscriber.php +++ b/EventListener/ObjectUploadSubscriber.php @@ -59,6 +59,7 @@ public function getSubscribedEvents() { return array( Events::preFlush, + Events::prePersist, Events::postPersist, Events::postUpdate, Events::postFlush, @@ -85,6 +86,19 @@ public function preFlush(PreFlushEventArgs $args) } } + /** + * Prepares upload file references for a new object implementing the UploadObjectInterface. + * + * @param LifecycleEventArgs $args + */ + public function prePersist(LifecycleEventArgs $args) + { + $object = $args->getObject(); + if ($object instanceof UploadObjectInterface) { + $this->prepareUploadFileReferences($object); + } + } + /** * Stores the file uploads. *