Doctrine/ORM/Provider/SharingProvider.php
private function addWhereForSharing(QueryBuilder $qb, array $subjects, array $sids)
    {
        $where = '';
        $parameters = [];

        foreach ($subjects as $i => $subject) {
            $class = 'subject'.$i.'_class';
            $id = 'subject'.$i.'_id';
            $parameters[$class] = $subject->getType();
            $parameters[$id] = $subject->getIdentifier();
            $where .= '' === $where ? '' : ' OR ';
            $where .= sprintf('(s.subjectClass = :%s AND s.subjectId = :%s)', $class, $id);
        }

        $qb->where($where);

        foreach ($parameters as $key => $value) {
            $qb->setParameter($key, $value);
        }

        return $this->addWhereSecurityIdentitiesForSharing($qb, $sids);
    }
private function addWhereForSharing(QueryBuilder $qb, array $subjects, array $sids)
    {
        $where = '';
        $parameters = [];

        foreach ($subjects as $i => $subject) {
            $class = 'subject'.$i.'_class';
            $id = 'subject'.$i.'_id';
            $parameters[$class] = $subject->getType();
            $parameters[$id] = $subject->getIdentifier();
            $where .= '' === $where ? '' : ' OR ';
            $where .= sprintf('(s.subjectClass = :%s AND s.subjectId = :%s)', $class, $id);
        }

        $qb->where($where);

        foreach ($parameters as $key => $value) {
            $qb->setParameter($key, $value);
        }

        return $this->addWhereSecurityIdentitiesForSharing($qb, $sids);
    }
private function addWhereForSharing ( QueryBuilder $ qb , array $ subjects , array $ sids ) { $ where = '' ; $ parameters = [ ] ; foreach ( $ subjects as $ i => $ subject ) { $ class = 'subject' . $ i . '_class' ; $ id = 'subject' . $ i . '_id' ; $ parameters [ $ class ] = $ subject -> getType ( ) ; $ parameters [ $ id ] = $ subject -> getIdentifier ( ) ; $ where .= '' === $ where ? '' : ' OR ' ; $ where .= sprintf ( '(s.subjectClass = :%s AND s.subjectId = :%s)' , $ class , $ id ) ; } $ qb -> where ( $ where ) ; foreach ( $ parameters as $ key => $ value ) { $ qb -> setParameter ( $ key , $ value ) ; } return $ this -> addWhereSecurityIdentitiesForSharing ( $ qb , $ sids ) ; }
Add where condition for sharing.

@param QueryBuilder                $qb       The query builder
@param SubjectIdentityInterface[]  $subjects The subjects
@param SecurityIdentityInterface[] $sids     The security identities

@return QueryBuilder
Add where condition for sharing .