@param \Doctrine\ORM\QueryBuilder $qb    Query builder
@param string                     $alias Alias

@return MetadataEntityRepositoryTrait
776570
protected function addEnabledFilter(QueryBuilder $qb, $alias = 'translations')
    {
        $qb->andWhere($alias.'.enabled = :enabled')->setParameter('enabled', true);

        return $this;
    }
918905
public function addAlias($alias = null)
    {
        return (new AuthorizationBuilder(TransactionType::ALIAS, $this))
            ->withAlias(AliasAction::ADD, $alias);
    }
511633
private function applyCriteriaToQueryBuilder(Criteria $criteria, QueryBuilder $qb, $prefix)
    {
        if ($criteria->getMode() === Criteria::MODE_OR) {
            $expr = $qb->expr()->orX();
        } else {
            $expr = $qb->expr()->andX();
        }
        foreach ($criteria as $criterium) {
            if ($criterium instanceof Criteria) {
                $expr->add(
                    $this->applyCriteriaToQueryBuilder($criterium, $qb, $prefix)
                );
            } else {
                $this->applyCriteriumToQueryBuilder($criterium, $qb, $expr, $prefix);
            }
        }

        return $expr;
    }
440579
public static function getEntityClassByAlias(string $alias, QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): string
    {
        if (!\in_array($alias, $queryBuilder->getAllAliases(), true)) {
            throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
        }

        $rootAliasMap = self::mapRootAliases($queryBuilder->getRootAliases(), $queryBuilder->getRootEntities());

        if (isset($rootAliasMap[$alias])) {
            return $rootAliasMap[$alias];
        }

        $metadata = null;

        foreach (self::traverseJoins($alias, $queryBuilder, $managerRegistry) as [$currentMetadata]) {
            $metadata = $currentMetadata;
        }

        if (null === $metadata) {
            throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
        }

        return $metadata->getName();
    }
259969
public function addNotHiddenFilter(QueryBuilder $qb, $alias = 'translations')
    {
        $qb->andWhere($alias.'.hidden = :hidden')->setParameter('hidden', false);

        return $this;
    }
1082361
public function createResultSetMappingBuilder($alias)
    {
        $rsm = new ResultSetMappingBuilder($this->em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
        $rsm->addRootEntityFromClassMetadata($this->entityName, $alias);

        return $rsm;
    }
1007300
public function getTableForAlias($alias)
    {
        if (isset($this->aliases[$alias])) {
            return $this->aliases[$alias];
        }

        return null;
    }
662409
private function filterByAvailability(QueryBuilder $qb)
    {
        $alias = $qb->getAllAliases()[0];
        $qb->andWhere($alias . '.reservationMovement IS NULL');

        return $qb;
    }
270759
protected function getCollectionQueryBuilder($alias = null, $indexBy = null)
    {
        $qb = $this->traitGetCollectionQueryBuilder($alias, $indexBy);

        $alias = $alias ?: $this->getAlias();

        return $qb
            ->addSelect('translation')
            ->leftJoin($alias . '.translations', 'translation');
    }
1368776
public function getFilter(QueryBuilder $qb, $dqlAlias)
    {
        return (string) $qb->expr()->not($this->child->getFilter($qb, $dqlAlias));
    }
645688
public function getTableByAlias($alias)
    {
        return $this->hasTableAlias($alias) ? $this->getExpression($this->getHash($alias)) : null;
    }
651252
public function filterWithChildren($qb, $alias, $field, $value)
    {
        // Check whether it is a numeric value because we could get a string number.
        if (!($value['value'] && is_numeric($value['value']))) {
            return null;
        }

        // Get the parent item
        $parentQb = clone $qb;
        $parentQb->where($parentQb->expr()->eq(sprintf('%s.id', $alias), ':id'));
        $parentQb->setParameter('id', (int)$value['value']);
        $currentItem = $parentQb->getQuery()->getOneOrNullResult();

        if ($currentItem === null) {
            return null;
        }

        $qb->where(
            $qb->expr()->andX(
                $qb->expr()->eq(sprintf('%s.root', $alias), ':root'),
                $qb->expr()->orX(
                    $qb->expr()->andX(
                        $qb->expr()->lt(sprintf('%s.lft', $alias), ':left'),
                        $qb->expr()->gt(sprintf('%s.rgt', $alias), ':right')
                    ),
                    $qb->expr()->between(sprintf('%s.lft', $alias), ':left', ':right')
                )
            )
        );

        $qb->setParameter('root', $currentItem->getRoot());
        $qb->setParameter('left', $currentItem->getLft());
        $qb->setParameter('right', $currentItem->getRgt());

        return true;
    }
1322460
public function alias(string $alias, ?string $table = null): IQueryBuilderHandler
    {
        if ($table === null && isset($this->statements['tables'][0]) === true) {
            $table = $this->statements['tables'][0];
        } else {
            $table = $this->tablePrefix . $table;
        }

        $this->statements['aliases'][$table] = \strtolower($alias);

        return $this;
    }
104790
public static function findByMetadataQueryBuilder(
        QueryBuilder $qb,
        $join,
        array $metadata,
        $alias = 'metadata',
        $operator = 'eq',
        $whereOperator = 'and'
    ) {
        $qb->join($join, $alias);

        foreach ($metadata as $key => $data) {
            $andX = $qb->expr()->andX();

            foreach ($data as $field => $value) {
                $itemOperator = $operator;

                if (is_array($value)) {
                    $value = $value['value'];
                    $itemOperator = $value['operator'];
                }

                $parameterName = sprintf('%s_%s_%s', $alias, $field, $key);
                $andX->add(call_user_func_array(
                    array($qb->expr(), $itemOperator),
                    array(
                        sprintf('%s.%s', $alias, $field),
                        sprintf(':%s', $parameterName),
                    )
                ));

                $qb->setParameter($parameterName, $value);
            }

            call_user_func_array(array($qb, sprintf('%sWhere', $whereOperator)), array($andX));
        }

        return $qb;
    }
380231
public function createQueryBuilder($alias, $indexBy = null)
    {
        return $this->_em->createQueryBuilder()
            ->select($alias)
            ->from($this->_entityName, $alias, $indexBy);
    }
879641
public function subQuery(QueryBuilderHandler $queryBuilder, $alias = null)
    {
        $sql = '(' . $queryBuilder->getQuery()->getRawSql() . ')';
        if ($alias) {
            $sql = $sql . ' as ' . $alias;
        }

        return $queryBuilder->raw($sql);
    }
727676
public function alias($alias = null)
    {
        if ($alias === null) {
            return $this->_alias;
        }
        $this->_alias = $alias;

        return $this;
    }