Hi.

Quite a few posts out there asking how you can disable lazy loading, but 
most of all turn in a direction to use the the hydration mode array. 
Unfortunatly, this doesn't enable me to use the generated entity classes 
that I already defined for doctrine and doesn't allow a proper interface to 
be set

Details:

Assume that I defined the entities

namespace Foo\Entity;
class Qux {
   protected $extraData;
   public getExtraData() { ...}
   public setExtraData($extraData) { ...}
}

class Bar {

   protected $quxs;
   public addQux(Qux $qux) { ... }
   public removeQux(Qux $qux) { ... }
   public getQuxs() { ... } 
}




Lets say that depending on the context (for instance, for security reasons) 
the service layer decides to call either call database layer that has two 
methods NoDetails or Complete.

/**
 * @returns Bar[]
 **/
public fetchBar($context) {
   if($this->security->hasFullAccess($context))
      return $this->dbal->getBarComplete();
   else
      return $this->dbal->getBarNoDetails();
}

which are implemented as followed:

/**
 * @returns Bar[]
 **/
public getBarNoDetails() {
   $entityManager->createNativeQuery("Select b from Foo:Bar b")->getResults
();
}

/**
 * @returns Bar[]
 **/
public getBarComplete() {
   $entityManager->createNativeQuery("Select b,q from Foo:Bar b join b.Qux 
q")
->getResults();
}




Now, since I've set to use lazy loading I'm not really creating a 
difference to the poing of view of the caller, since, in both scenarios he 
can still do

$bars[0]->getQuxs() 

the only difference would be that it would take longer to respond because 
of the lazy loading.

But, if I use 

 ...->getArrayResults();

I manage to sucessfully restrict the access to the Qux collection, but now 
the interface is broken, because I'm not returning a set of 
Foo\Entity\Bar[] but instead an array. And cannot longer to $bars[0]->
getQuxs() and I must use instead $bars[0]->quxs. 

Thoughts?

Thx

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to