lib/CosmoW/Riak/Collection.php
public function aggregate(array $pipeline, array $options = array() /* , array $op, ... */)
    {
        /* If the single array argument contains a zeroth index, consider it an
         * array of pipeline operators. Otherwise, assume that each argument is
         * a pipeline operator.
         */
        if ( ! array_key_exists(0, $pipeline)) {
            $pipeline = func_get_args();
            $options = array();
        }

        if ($this->eventManager->hasListeners(Events::preAggregate)) {
            $this->eventManager->dispatchEvent(Events::preAggregate, new AggregateEventArgs($this, $pipeline, $options));
        }

        $result = $this->doAggregate($pipeline, $options);

        if ($this->eventManager->hasListeners(Events::postAggregate)) {
            $eventArgs = new MutableEventArgs($this, $result);
            $this->eventManager->dispatchEvent(Events::postAggregate, $eventArgs);
            $result = $eventArgs->getData();
        }

        return $result;
    }
public function aggregate(array $pipeline, array $options = array() /* , array $op, ... */)
    {
        /* If the single array argument contains a zeroth index, consider it an
         * array of pipeline operators. Otherwise, assume that each argument is
         * a pipeline operator.
         */
        if ( ! array_key_exists(0, $pipeline)) {
            $pipeline = func_get_args();
            $options = array();
        }

        if ($this->eventManager->hasListeners(Events::preAggregate)) {
            $this->eventManager->dispatchEvent(Events::preAggregate, new AggregateEventArgs($this, $pipeline, $options));
        }

        $result = $this->doAggregate($pipeline, $options);

        if ($this->eventManager->hasListeners(Events::postAggregate)) {
            $eventArgs = new MutableEventArgs($this, $result);
            $this->eventManager->dispatchEvent(Events::postAggregate, $eventArgs);
            $result = $eventArgs->getData();
        }

        return $result;
    }
public function aggregate ( array $ pipeline , array $ options = array ( ) /* , array $op, ... */ ) { /* If the single array argument contains a zeroth index, consider it an
         * array of pipeline operators. Otherwise, assume that each argument is
         * a pipeline operator.
         */ if ( ! array_key_exists ( 0 , $ pipeline ) ) { $ pipeline = func_get_args ( ) ; $ options = array ( ) ; } if ( $ this -> eventManager -> hasListeners ( Events :: preAggregate ) ) { $ this -> eventManager -> dispatchEvent ( Events :: preAggregate , new AggregateEventArgs ( $ this , $ pipeline , $ options ) ) ; } $ result = $ this -> doAggregate ( $ pipeline , $ options ) ; if ( $ this -> eventManager -> hasListeners ( Events :: postAggregate ) ) { $ eventArgs = new MutableEventArgs ( $ this , $ result ) ; $ this -> eventManager -> dispatchEvent ( Events :: postAggregate , $ eventArgs ) ; $ result = $ eventArgs -> getData ( ) ; } return $ result ; }
Invokes the aggregate command.

This method will dispatch preAggregate and postAggregate events.

By default, the results from a non-cursor aggregate command will be
returned as an ArrayIterator; however, if the pipeline ends in an $out
operator, a cursor on the output collection will be returned instead.

If the "cursor" option is true or an array, a command cursor will be
returned (requires driver >= 1.5.0 and Riak >= 2.6).

@see http://php.net/manual/en/mongocollection.aggregate.php
@see http://docs.mongodb.org/manual/reference/command/aggregate/
@param array $pipeline Array of pipeline operators, or the first operator
@param array $options  Command options (if $pipeline was an array of pipeline operators)
@param array $op,...   Additional operators (if $pipeline was the first)
@return Iterator
@throws ResultException if the command fails
Invokes the aggregate command .