You do not need to retrieve the source object, since the Proxy class must be 100% transparent to your code.
If you need to serialize a document, for example, to send it via the API, be sure to correctly implement the serialize() method in your document.
If you still need to get a referenced document without a proxy, you can either prime() it, or get it using a separate request specifying hydrate(false) :
$user = $dm->createQueryBuilder('Person') ->field('_id')->equals($user->getPerson()->getId()) ->hydrate(false)
See: Doctrine ODM Doc: Disable Hydration for more information.
Madarco
source share