src/Repository/Doctrine/Repository.php
protected function applyScopesToQueryBuilder(QueryBuilder $qb, array $scopes) {
        foreach((array) $scopes as $scope) {
            $method = 'scope' . ucfirst($scope);
            if(method_exists($this, $method)) {
                $qb = $this->{$method}($qb);
            } else {
                throw new InvalidArgumentException('Scope \'' . $scope . '\' not found');
            }
        }
        return $qb;
    }
protected function applyScopesToQueryBuilder(QueryBuilder $qb, array $scopes) {
        foreach((array) $scopes as $scope) {
            $method = 'scope' . ucfirst($scope);
            if(method_exists($this, $method)) {
                $qb = $this->{$method}($qb);
            } else {
                throw new InvalidArgumentException('Scope \'' . $scope . '\' not found');
            }
        }
        return $qb;
    }
Creates a new QueryBuilder instance that is pre-populated for this entity name.
Applies scopes to the query builder as well.

@param array  $scopes
@param QueryBuilder $qb
@throws InvalidArgumentException if the scope was not found
@return QueryBuilder