Newer
Older
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\ElasticsearchBundle\DSL\Sort;
use ONGR\ElasticsearchBundle\DSL\BuilderInterface;
/**
* Holds all the values required for basic sorting.
*/
class Sort extends AbstractSort
{
/**
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
*/
private $nestedFilter;
/**
* @param string $field Field name.
* @param string $order Order direction.
* @param BuilderInterface $nestedFilter Filter for sorting.
* @param string $mode Multi-valued field sorting mode [MODE_MIN, MODE_MAX, MODE_AVG, MODE_SUM].
*/
public function __construct($field, $order = self::ORDER_ASC, BuilderInterface $nestedFilter = null, $mode = null)
{
parent::__construct($field, $order, $mode);
$this->setNestedFilter($nestedFilter);
}
/**
* Sets nested filter.
*
* @param BuilderInterface $nestedFilter
*/
public function setNestedFilter($nestedFilter)
{
$this->nestedFilter = $nestedFilter;
}
/**
* Returns nested filter.
*
* @return BuilderInterface
*/
public function getNestedFilter()
{
return $this->nestedFilter;
}
/**
* @return string
*/
public function getType()
{
return $this->getField();
}
/**
* {@inheritdoc}
*/
public function toArray()
{
$value = parent::toArray();
if ($this->getNestedFilter() !== null) {
$value['nested_filter'][$this->getNestedFilter()->getType()] = $this->getNestedFilter()->toArray();
}
return $value;
}
}