Elastica\Aggregation\AbstractAggregation::toArray PHP Method

toArray() public method

public toArray ( ) : array
return array
    public function toArray()
    {
        $array = parent::toArray();
        if (array_key_exists('global_aggregation', $array)) {
            // compensate for class name GlobalAggregation
            $array = ['global' => new \stdClass()];
        }
        if (sizeof($this->_aggs)) {
            $array['aggs'] = $this->_convertArrayable($this->_aggs);
        }
        return $array;
    }

Usage Example

Example #1
0
 /**
  * @throws InvalidException If buckets path is not set
  *
  * @return array
  */
 public function toArray()
 {
     if (!$this->hasParam('buckets_path')) {
         throw new InvalidException('Buckets path is required');
     }
     return parent::toArray();
 }
All Usage Examples Of Elastica\Aggregation\AbstractAggregation::toArray