public function getPipeline() : array
    {
        $pipeline = array_map(
            static function (Stage $stage) {
                return $stage->getExpression();
            },
            $this->stages
        );

        if ($this->getStage(0) instanceof Stage\GeoNear) {
            $pipeline[0]['$geoNear']['query'] = $this->applyFilters($pipeline[0]['$geoNear']['query']);
        } elseif ($this->getStage(0) instanceof Stage\IndexStats) {
            // Don't apply any filters when using an IndexStats stage: since it
            // needs to be the first pipeline stage, prepending a match stage
            // with discriminator information will not work

            return $pipeline;
        } else {
            $matchExpression = $this->applyFilters([]);
            if ($matchExpression !== []) {
                array_unshift($pipeline, ['$match' => $matchExpression]);
            }
        }

        return $pipeline;
    }
public function getPipeline() : array
    {
        $pipeline = array_map(
            static function (Stage $stage) {
                return $stage->getExpression();
            },
            $this->stages
        );

        if ($this->getStage(0) instanceof Stage\GeoNear) {
            $pipeline[0]['$geoNear']['query'] = $this->applyFilters($pipeline[0]['$geoNear']['query']);
        } elseif ($this->getStage(0) instanceof Stage\IndexStats) {
            // Don't apply any filters when using an IndexStats stage: since it
            // needs to be the first pipeline stage, prepending a match stage
            // with discriminator information will not work

            return $pipeline;
        } else {
            $matchExpression = $this->applyFilters([]);
            if ($matchExpression !== []) {
                array_unshift($pipeline, ['$match' => $matchExpression]);
            }
        }

        return $pipeline;
    }
public function getPipeline ( ) : array { $ pipeline = array_map ( static function ( Stage $ stage ) { return $ stage -> getExpression ( ) ; } , $ this -> stages ) ; if ( $ this -> getStage ( 0 ) instanceof Stage \ GeoNear ) { $ pipeline [ 0 ] [ '$geoNear' ] [ 'query' ] = $ this -> applyFilters ( $ pipeline [ 0 ] [ '$geoNear' ] [ 'query' ] ) ; } elseif ( $ this -> getStage ( 0 ) instanceof Stage \ IndexStats ) { // Don't apply any filters when using an IndexStats stage: since it // needs to be the first pipeline stage, prepending a match stage // with discriminator information will not work return $ pipeline ; } else { $ matchExpression = $ this -> applyFilters ( [ ] ) ; if ( $ matchExpression !== [ ] ) { array_unshift ( $ pipeline , [ '$match' => $ matchExpression ] ) ; } } return $ pipeline ; }
Returns the assembled aggregation pipeline

For pipelines where the first stage is a $geoNear stage, it will apply
the document filters and discriminator queries to the query portion of
the geoNear operation. For all other pipelines, it prepends a $match stage
containing the required query.
Returns the assembled aggregation pipeline