|
11 | 11 |
|
12 | 12 | namespace WobbleCode\RestBundle\EventListener; |
13 | 13 |
|
| 14 | +use WobbleCode\RestBundle\Event\PreSerializeConfigurationEvent; |
14 | 15 | use Symfony\Component\HttpFoundation\Response; |
15 | 16 | use Symfony\Component\HttpFoundation\Request; |
16 | 17 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
|
21 | 22 | use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; |
22 | 23 | use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; |
23 | 24 | use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
| 25 | +use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
24 | 26 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
25 | 27 | use JMS\Serializer\Serializer; |
26 | 28 | use JMS\Serializer\SerializationContext; |
@@ -61,8 +63,10 @@ class RestSubscriber implements EventSubscriberInterface |
61 | 63 | */ |
62 | 64 | public function __construct( |
63 | 65 | Serializer $serializer, |
64 | | - MapperInterface $errorMapper |
| 66 | + MapperInterface $errorMapper, |
| 67 | + EventDispatcherInterface $eventDispatcher |
65 | 68 | ) { |
| 69 | + $this->dispatcher = $eventDispatcher; |
66 | 70 | $this->serializationContext = new SerializationContext(); |
67 | 71 | $this->serializationContext->setSerializeNull(true); |
68 | 72 | $this->serializationContext->enableMaxDepthChecks(); |
@@ -201,7 +205,10 @@ public function onKernelView(GetResponseForControllerResultEvent $event) |
201 | 205 | return; |
202 | 206 | }; |
203 | 207 |
|
204 | | - $restConfig = $request->attributes->get('_rest'); |
| 208 | + $preRestConfig = $request->attributes->get('_rest'); |
| 209 | + $restEvent = new PreSerializeConfigurationEvent($preRestConfig); |
| 210 | + $this->dispatcher->dispatch(PreSerializeConfigurationEvent::NAME, $restEvent); |
| 211 | + $restConfig = $restEvent->getConfiguration(); |
205 | 212 | $parameters = $event->getControllerResult(); |
206 | 213 |
|
207 | 214 | /** |
|
0 commit comments