File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 33namespace Krak \ApiPlatformExtra \DataPersister ;
44
55use ApiPlatform \Core \DataPersister \DataPersisterInterface ;
6+ use Symfony \Component \Messenger \Envelope ;
67use Symfony \Component \Messenger \MessageBusInterface ;
8+ use Symfony \Component \Messenger \Stamp \HandledStamp ;
79
810final class MessageBusDataPersister implements DataPersisterInterface
911{
@@ -32,7 +34,16 @@ public function supports($data): bool {
3234 * @return object|void Void will not be supported in API Platform 3, an object should always be returned
3335 */
3436 public function persist ($ data ) {
35- return $ this ->messageBus ->dispatch ($ data );
37+ $ envelope = $ this ->messageBus ->dispatch ($ data );
38+ if ($ envelope instanceof Envelope === false ) {
39+ return $ envelope ;
40+ }
41+
42+ if (null === $ stamp = $ envelope ->last (HandledStamp::class)) {
43+ return $ data ;
44+ }
45+
46+ return $ stamp ->getResult ();
3647 }
3748
3849 /**
You can’t perform that action at this time.
0 commit comments