public function populateRequestParams(FilterControllerEvent $event)
 {
     if ($event->getController()[0] instanceof ApiControllerInterface) {
         $request = $event->getRequest();
         $resource = $this->resourceResolver->resolve($request->attributes->get('resource'));
         $action = $this->actionResolver->resolve($resource, $request->attributes->get('actionName'), $request->getMethod(), null !== $request->attributes->get('identifier'));
         $content = $request->getContent();
         $payload = empty($content) ? null : $this->serializer->deserialize($content, 'array', 'json');
         $request->attributes->set(self::API_REQUEST_RESOURCE, $resource);
         $request->attributes->set(self::API_REQUEST_ACTION, $action);
         $request->attributes->set(self::API_REQUEST_PAYLOAD, $payload);
     }
 }
 function it_should_recognize_and_mark_api_requests(ApiControllerInterface $controller, FilterControllerEvent $event, ResourceResolver $resourceResolver, ActionManager $actionResolver, SerializerInterface $serializer, ActionInterface $action)
 {
     $payload = ['foo' => 'bar', 'baz' => 'qux'];
     $resource = 'baz';
     $fqcn = 'BarBundle/Entity/Bar';
     $actionName = 'fooAction';
     $httpMethod = 'GET';
     $identifier = null;
     $request = new Request([], [], ['actionName' => $actionName, 'resource' => 'baz', 'identifier' => $identifier], [], [], [], json_encode($payload));
     $resourceResolver->resolve($resource)->willReturn($fqcn);
     $actionResolver->resolve($fqcn, $actionName, $httpMethod, !is_null($identifier))->willReturn($action);
     $event->getRequest()->willReturn($request);
     $event->getController()->willReturn([$controller]);
     $this->setSerializer($serializer);
     $this->setResourceResolver($resourceResolver);
     $this->setActionResolver($actionResolver);
     $this->populateRequestParams($event);
 }