Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 73519d0

Browse files
committed
Merge pull request #37 from niels-nijens/fix-upload-for-new-objects
Fix preparation of file uploads for new objects in ObjectUploadSubscriber
2 parents ccf88fd + a023ef8 commit 73519d0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

EventListener/ObjectUploadSubscriber.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function getSubscribedEvents()
5959
{
6060
return array(
6161
Events::preFlush,
62+
Events::prePersist,
6263
Events::postPersist,
6364
Events::postUpdate,
6465
Events::postFlush,
@@ -85,6 +86,19 @@ public function preFlush(PreFlushEventArgs $args)
8586
}
8687
}
8788

89+
/**
90+
* Prepares upload file references for a new object implementing the UploadObjectInterface.
91+
*
92+
* @param LifecycleEventArgs $args
93+
*/
94+
public function prePersist(LifecycleEventArgs $args)
95+
{
96+
$object = $args->getObject();
97+
if ($object instanceof UploadObjectInterface) {
98+
$this->prepareUploadFileReferences($object);
99+
}
100+
}
101+
88102
/**
89103
* Stores the file uploads.
90104
*

0 commit comments

Comments
 (0)