EventListener/SerializerListener.php
public function onKernelController(FilterControllerEvent $event)
    {
        if (!is_array($controller = $event->getController())) {
            return;
        }

        $request = $event->getRequest();

        $method = new \ReflectionMethod($controller[0], $controller[1]);

        if ($this->isHydraOperation($method)) {
            $request->attributes->set('__hydra_serialize', true);

            // TODO Add support for serialization groups and other serialization formats
        }
    }
public function onKernelController(FilterControllerEvent $event)
    {
        if (!is_array($controller = $event->getController())) {
            return;
        }

        $request = $event->getRequest();

        $method = new \ReflectionMethod($controller[0], $controller[1]);

        if ($this->isHydraOperation($method)) {
            $request->attributes->set('__hydra_serialize', true);

            // TODO Add support for serialization groups and other serialization formats
        }
    }
Marks request that whose controller return value should be serialized
by the Hydra serializer

@param FilterControllerEvent $event A FilterControllerEvent instance