Skip to content

Instantly share code, notes, and snippets.

View Jaap-van-Hengstum's full-sized avatar

Jaap van Hengstum Jaap-van-Hengstum

View GitHub Profile
@Jaap-van-Hengstum
Jaap-van-Hengstum / DoctrineProxyHandler.php
Last active September 19, 2021 15:04
Disable lazy loading when serializing Doctrine 2 objects with JMS Serializer
namespace MyApp\ApiBundle\Serializer;
use JMS\Serializer\Context;
use JMS\Serializer\GraphNavigator;
use JMS\Serializer\Handler\SubscribingHandlerInterface;
use JMS\Serializer\VisitorInterface;
use JMS\Serializer\XmlSerializationVisitor;
class DoctrineProxyHandler implements SubscribingHandlerInterface
{