Thank you, seems that it is exact what I need.

вторник, 16 декабря 2014 г., 13:26:01 UTC+3 пользователь Pavel Sokolov 
написал:
>
> 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.

Reply via email to