How to force Doctrine 2 to return an object instead of a proxy server

I'm trying to implement deep copy functions with Doctrine 2, and I almost have it, except for a method on one of my entities that tries to cut certain records from an association before returning the collection.

The problem is that when I call getRoofAreas () below, I get an array of Proxy objects that I don't like in my deep code:

/** * @OneToMany(targetEntity="\Entities\QuotingRoofAreas", mappedBy="customerId", cascade={"persist"}) * @OrderBy({"areaIndex" = "ASC"}) */ private $roofAreas; public function getRoofAreas() { $em = \Zend_Registry::get('em'); $q = $em->createQuery("select ra from \Entities\QuotingRoofAreas ra where ra.dateDeleted IS NULL and ra.customerId = " . $this->getId()); return $q->getResult(); } 

but if I changed this to:

 /** * @OneToMany(targetEntity="\Entities\QuotingRoofAreas", mappedBy="customerId", cascade={"persist"}) * @OrderBy({"areaIndex" = "ASC"}) */ private $roofAreas; public function getRoofAreas() { return $roofAreas; } 

then it will return a permanent collection that, when repeated, will receive the Entity objects that I want. The latter approach does not exclude remote areas of the roof, which is mandatory for my use.

Is there a way to get an Entity object for a proxy object?

Thanks in advance for any help anyone can provide.

+4
source share
1 answer

All Articles