You are probably looking for SQL-level filters: http://doctrine-orm.readthedocs.org/en/latest/reference/filters.html
Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 16 December 2014 at 11:26, Pavel Sokolov <[email protected]> wrote: > > Is it possible to filter Entity in one place, without any depends from any > DQL query? > > For example, I have to entites: > > class User { > /** @ORM\Id */ > protected $id; > /** @ORM\ManyToOne(targetEntity="Organisation") */ > protected $organisation; > } > > class Organisation { > /** @ORM\Id */ > protected $id; > } > > class Document { > /** @ORM\Id */ > protected $id; > /** @ORM\ManyToOne(targetEntity="Organisation") */ > protected $organisation; > } > > > > Users can login to web portal. > How to filter Document in EVERY access to Document from ANY DQL query? > May be it is possible to apply something like callback which can install > filter Document.organisation=CurrentUser.organisation to any DQL query: > class Document { > .. > public myCallBackWhichExecutedOnEveryDqlQuery($query){ > $currentUser=Core::getCurrentUser(); > $query->andWhere('User.organisation=:currentUserOrganisation > ')->setParameter('currentUserOrganisation',$currentUser->getOrganisation() > ); > } > .. > } > > -- > 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. > -- 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.
