public function aggregate(array $pipeline, array $op = [])
    {
        if (! TypeConverter::isNumericArray($pipeline)) {
            $operators = func_get_args();
            $pipeline = [];
            $options = [];

            $i = 0;
            foreach ($operators as $operator) {
                $i++;
                if (! is_array($operator)) {
                    trigger_error("Argument $i is not an array", E_USER_WARNING);
                    return;
                }

                $pipeline[] = $operator;
            }
        } else {
            $options = $op;
        }

        if (isset($options['cursor'])) {
            $options['useCursor'] = true;

            if (isset($options['cursor']['batchSize'])) {
                $options['batchSize'] = $options['cursor']['batchSize'];
            }

            unset($options['cursor']);
        } else {
            $options['useCursor'] = false;
        }

        try {
            $cursor = $this->collection->aggregate(TypeConverter::fromLegacy($pipeline), $options);

            return [
                'ok' => 1.0,
                'result' => TypeConverter::toLegacy($cursor),
                'waitedMS' => 0,
            ];
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e, 'MongoResultException');
        }
    }
public function aggregate(array $pipeline, array $op = [])
    {
        if (! TypeConverter::isNumericArray($pipeline)) {
            $operators = func_get_args();
            $pipeline = [];
            $options = [];

            $i = 0;
            foreach ($operators as $operator) {
                $i++;
                if (! is_array($operator)) {
                    trigger_error("Argument $i is not an array", E_USER_WARNING);
                    return;
                }

                $pipeline[] = $operator;
            }
        } else {
            $options = $op;
        }

        if (isset($options['cursor'])) {
            $options['useCursor'] = true;

            if (isset($options['cursor']['batchSize'])) {
                $options['batchSize'] = $options['cursor']['batchSize'];
            }

            unset($options['cursor']);
        } else {
            $options['useCursor'] = false;
        }

        try {
            $cursor = $this->collection->aggregate(TypeConverter::fromLegacy($pipeline), $options);

            return [
                'ok' => 1.0,
                'result' => TypeConverter::toLegacy($cursor),
                'waitedMS' => 0,
            ];
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e, 'MongoResultException');
        }
    }
public function aggregate ( array $ pipeline , array $ op = [ ] ) { if ( ! TypeConverter :: isNumericArray ( $ pipeline ) ) { $ operators = func_get_args ( ) ; $ pipeline = [ ] ; $ options = [ ] ; $ i = 0 ; foreach ( $ operators as $ operator ) { $ i ++ ; if ( ! is_array ( $ operator ) ) { trigger_error ( "Argument $i is not an array" , E_USER_WARNING ) ; return ; } $ pipeline [ ] = $ operator ; } } else { $ options = $ op ; } if ( isset ( $ options [ 'cursor' ] ) ) { $ options [ 'useCursor' ] = true ; if ( isset ( $ options [ 'cursor' ] [ 'batchSize' ] ) ) { $ options [ 'batchSize' ] = $ options [ 'cursor' ] [ 'batchSize' ] ; } unset ( $ options [ 'cursor' ] ) ; } else { $ options [ 'useCursor' ] = false ; } try { $ cursor = $ this -> collection -> aggregate ( TypeConverter :: fromLegacy ( $ pipeline ) , $ options ) ; return [ 'ok' => 1.0 , 'result' => TypeConverter :: toLegacy ( $ cursor ) , 'waitedMS' => 0 , ] ; } catch ( \ MongoDB \ Driver \ Exception \ Exception $ e ) { throw ExceptionConverter :: toLegacy ( $ e , 'MongoResultException' ) ; } }
Perform an aggregation using the aggregation framework

@link http://www.php.net/manual/en/mongocollection.aggregate.php
@param array $pipeline
@param array $op
@return array
Perform an aggregation using the aggregation framework