Doctrine/ORM/Filter/Listener/PrivateSharingSubscriber.php
private function buildSharingFilter(GetFilterEvent $event)
    {
        $targetEntity = $event->getTargetEntity();
        $targetTableAlias = $event->getTargetTableAlias();
        $connection = $event->getConnection();
        $classname = $connection->quote($targetEntity->getName());
        $meta = $event->getSharingClassMetadata();
        $identifier = DoctrineUtils::castIdentifier($targetEntity, $connection);

        return <<<SELECTCLAUSE
{$targetTableAlias}.{$meta->getColumnName('id')} IN (SELECT
    s.{$meta->getColumnName('subjectId')}{$identifier}
FROM
    {$meta->getTableName()} s
WHERE
    s.{$meta->getColumnName('subjectClass')} = {$classname}
    AND s.{$meta->getColumnName('enabled')} IS TRUE
    AND (s.{$meta->getColumnName('startedAt')} IS NULL OR s.{$meta->getColumnName('startedAt')} <= CURRENT_TIMESTAMP)
    AND (s.{$meta->getColumnName('endedAt')} IS NULL OR s.{$meta->getColumnName('endedAt')} >= CURRENT_TIMESTAMP)
    AND ({$this->addWhereSecurityIdentitiesForSharing($event, $meta)})
GROUP BY
    s.{$meta->getColumnName('subjectId')})
SELECTCLAUSE;
    }
private function buildSharingFilter(GetFilterEvent $event)
    {
        $targetEntity = $event->getTargetEntity();
        $targetTableAlias = $event->getTargetTableAlias();
        $connection = $event->getConnection();
        $classname = $connection->quote($targetEntity->getName());
        $meta = $event->getSharingClassMetadata();
        $identifier = DoctrineUtils::castIdentifier($targetEntity, $connection);

        return <<<SELECTCLAUSE
{$targetTableAlias}.{$meta->getColumnName('id')} IN (SELECT
    s.{$meta->getColumnName('subjectId')}{$identifier}
FROM
    {$meta->getTableName()} s
WHERE
    s.{$meta->getColumnName('subjectClass')} = {$classname}
    AND s.{$meta->getColumnName('enabled')} IS TRUE
    AND (s.{$meta->getColumnName('startedAt')} IS NULL OR s.{$meta->getColumnName('startedAt')} <= CURRENT_TIMESTAMP)
    AND (s.{$meta->getColumnName('endedAt')} IS NULL OR s.{$meta->getColumnName('endedAt')} >= CURRENT_TIMESTAMP)
    AND ({$this->addWhereSecurityIdentitiesForSharing($event, $meta)})
GROUP BY
    s.{$meta->getColumnName('subjectId')})
SELECTCLAUSE;
    }
private function buildSharingFilter ( GetFilterEvent $ event ) { $ targetEntity = $ event -> getTargetEntity ( ) ; $ targetTableAlias = $ event -> getTargetTableAlias ( ) ; $ connection = $ event -> getConnection ( ) ; $ classname = $ connection -> quote ( $ targetEntity -> getName ( ) ) ; $ meta = $ event -> getSharingClassMetadata ( ) ; $ identifier = DoctrineUtils :: castIdentifier ( $ targetEntity , $ connection ) ; return  <<<SELECTCLAUSE
{$targetTableAlias}.{$meta->getColumnName('id')} IN (SELECT
    s.{$meta->getColumnName('subjectId')}{$identifier}
FROM
    {$meta->getTableName()} s
WHERE
    s.{$meta->getColumnName('subjectClass')} = {$classname}
    AND s.{$meta->getColumnName('enabled')} IS TRUE
    AND (s.{$meta->getColumnName('startedAt')} IS NULL OR s.{$meta->getColumnName('startedAt')} <= CURRENT_TIMESTAMP)
    AND (s.{$meta->getColumnName('endedAt')} IS NULL OR s.{$meta->getColumnName('endedAt')} >= CURRENT_TIMESTAMP)
    AND ({$this->addWhereSecurityIdentitiesForSharing($event, $meta)})
GROUP BY
    s.{$meta->getColumnName('subjectId')})
SELECTCLAUSE ; }
Build the query filter with sharing entries.

@param GetFilterEvent $event The event

@return string
Build the query filter with sharing entries .