From 8736409bb81852fc9427a300ec6180e9c3158bf1 Mon Sep 17 00:00:00 2001 From: Kris Wallsmith Date: Wed, 28 Jun 2017 13:25:30 -0700 Subject: [PATCH] do not disappear type params --- .../Subscriber/DoctrineProxySubscriber.php | 2 +- .../Subscriber/DoctrineProxySubscriberTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/EventDispatcher/Subscriber/DoctrineProxySubscriber.php b/src/EventDispatcher/Subscriber/DoctrineProxySubscriber.php index 0272ac633..78d9e25e4 100644 --- a/src/EventDispatcher/Subscriber/DoctrineProxySubscriber.php +++ b/src/EventDispatcher/Subscriber/DoctrineProxySubscriber.php @@ -84,7 +84,7 @@ public function onPreSerialize(PreSerializeEvent $event) $object->__load(); if (!$virtualType) { - $event->setType(get_parent_class($object)); + $event->setType(get_parent_class($object), $type['params']); } } diff --git a/tests/Serializer/EventDispatcher/Subscriber/DoctrineProxySubscriberTest.php b/tests/Serializer/EventDispatcher/Subscriber/DoctrineProxySubscriberTest.php index dc782cd2f..ebb379641 100644 --- a/tests/Serializer/EventDispatcher/Subscriber/DoctrineProxySubscriberTest.php +++ b/tests/Serializer/EventDispatcher/Subscriber/DoctrineProxySubscriberTest.php @@ -130,6 +130,17 @@ public function testListenersDoNotChangeTypeOnProxiesAndVirtualTypes() $this->assertSame(['name' => 'foo', 'params' => []], $event->getType()); } + public function testOnPreSerializeMaintainsParams() + { + $object = new SimpleObjectProxy('foo', 'bar'); + $type = ['name' => SimpleObjectProxy::class, 'params' => ['baz']]; + + $event = $this->createEvent($object, $type); + $this->subscriber->onPreSerialize($event); + + $this->assertSame(['name' => SimpleObject::class, 'params' => ['baz']], $event->getType()); + } + protected function setUp() { $this->subscriber = new DoctrineProxySubscriber();