Skip to content
Snippets Groups Projects
Commit 644fbd55 authored by Mantas Jonušas's avatar Mantas Jonušas
Browse files

Added ParametersTrait in AbstractAgregation class

parent 180928bc
No related branches found
No related tags found
No related merge requests found
......@@ -13,12 +13,15 @@ namespace ONGR\ElasticsearchBundle\DSL\Aggregation;
use ONGR\ElasticsearchBundle\DSL\NamedBuilderBag;
use ONGR\ElasticsearchBundle\DSL\NamedBuilderInterface;
use ONGR\ElasticsearchBundle\DSL\ParametersTrait;
/**
* AbstractAggregation class.
*/
abstract class AbstractAggregation implements NamedBuilderInterface
{
use ParametersTrait;
const PREFIX = 'agg_';
/**
......@@ -113,7 +116,12 @@ abstract class AbstractAggregation implements NamedBuilderInterface
*/
public function toArray()
{
$result = [$this->getName() => [$this->getType() => $this->getArray()]];
$array = $this->getArray();
$result = [
$this->getName() => [
$this->getType() => is_array($array) ? $this->processArray($array) : $array,
],
];
if ($this->supportsNesting()) {
$nestedResult = $this->collectNestedAggregations();
......
......@@ -12,7 +12,6 @@
namespace ONGR\ElasticsearchBundle\DSL\Aggregation;
use ONGR\ElasticsearchBundle\DSL\Aggregation\Type\BucketingTrait;
use ONGR\ElasticsearchBundle\DSL\ParametersTrait;
use ONGR\ElasticsearchBundle\DSL\ScriptAwareTrait;
/**
......@@ -22,7 +21,6 @@ class TermsAggregation extends AbstractAggregation
{
use BucketingTrait;
use ScriptAwareTrait;
use ParametersTrait;
/**
* {@inheritdoc}
......@@ -44,6 +42,6 @@ class TermsAggregation extends AbstractAggregation
]
);
return $this->processArray($data);
return $data;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment