| @@ 19-67 (lines=49) @@ | ||
| 16 | /** |
|
| 17 | * Class representing ChildrenAggregation. |
|
| 18 | */ |
|
| 19 | class ChildrenAggregation extends AbstractAggregation |
|
| 20 | { |
|
| 21 | use BucketingTrait; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var string |
|
| 25 | */ |
|
| 26 | private $children; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * Return children. |
|
| 30 | * |
|
| 31 | * @return string |
|
| 32 | */ |
|
| 33 | public function getChildren() |
|
| 34 | { |
|
| 35 | return $this->children; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Sets children. |
|
| 40 | * |
|
| 41 | * @param string $children |
|
| 42 | */ |
|
| 43 | public function setChildren($children) |
|
| 44 | { |
|
| 45 | $this->children = $children; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * {@inheritdoc} |
|
| 50 | */ |
|
| 51 | public function getType() |
|
| 52 | { |
|
| 53 | return 'children'; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * {@inheritdoc} |
|
| 58 | */ |
|
| 59 | public function getArray() |
|
| 60 | { |
|
| 61 | if (count($this->getAggregations()) == 0) { |
|
| 62 | throw new \LogicException("Children aggregation `{$this->getName()}` has no aggregations added"); |
|
| 63 | } |
|
| 64 | ||
| 65 | return ['type' => $this->getChildren()]; |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||
| @@ 19-67 (lines=49) @@ | ||
| 16 | /** |
|
| 17 | * Class representing NestedAggregation. |
|
| 18 | */ |
|
| 19 | class NestedAggregation extends AbstractAggregation |
|
| 20 | { |
|
| 21 | use BucketingTrait; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var string |
|
| 25 | */ |
|
| 26 | private $path; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * Return path. |
|
| 30 | * |
|
| 31 | * @return string |
|
| 32 | */ |
|
| 33 | public function getPath() |
|
| 34 | { |
|
| 35 | return $this->path; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Sets path. |
|
| 40 | * |
|
| 41 | * @param string $path |
|
| 42 | */ |
|
| 43 | public function setPath($path) |
|
| 44 | { |
|
| 45 | $this->path = $path; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * {@inheritdoc} |
|
| 50 | */ |
|
| 51 | public function getType() |
|
| 52 | { |
|
| 53 | return 'nested'; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * {@inheritdoc} |
|
| 58 | */ |
|
| 59 | public function getArray() |
|
| 60 | { |
|
| 61 | if (count($this->getAggregations()) == 0) { |
|
| 62 | throw new \LogicException("Nested aggregation `{$this->getName()}` has no aggregations added"); |
|
| 63 | } |
|
| 64 | ||
| 65 | return ['path' => $this->getPath()]; |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||