Completed
Push — master ( 76ac79...60ae6d )
by Simonas
64:57
created

Filter/Widget/Range/AbstractRange.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\FilterManagerBundle\Filter\Widget\Range;
13
14
use ONGR\ElasticsearchDSL\Query\RangeQuery;
15
use ONGR\ElasticsearchDSL\Search;
16
use ONGR\FilterManagerBundle\Filter\FilterState;
17
use ONGR\FilterManagerBundle\Filter\Helper\FieldAwareInterface;
18
use ONGR\FilterManagerBundle\Filter\Helper\FieldAwareTrait;
19
use ONGR\FilterManagerBundle\Filter\Helper\ViewDataFactoryInterface;
20
use ONGR\FilterManagerBundle\Filter\ViewData\RangeAwareViewData;
21
use ONGR\FilterManagerBundle\Filter\Widget\AbstractSingleRequestValueFilter;
22
use ONGR\FilterManagerBundle\Search\SearchRequest;
23
24
/**
25
 * Class AbstractRangeFilter.
26
 */
27
abstract class AbstractRange extends AbstractSingleRequestValueFilter implements
0 ignored issues
show
Deprecated Code introduced by
The class ONGR\FilterManagerBundle...ingleRequestValueFilter has been deprecated with message: Will be renamed to AbstractFilter.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
28
    FieldAwareInterface,
0 ignored issues
show
Deprecated Code introduced by
The interface ONGR\FilterManagerBundle...per\FieldAwareInterface has been deprecated with message: FieldAwareInterface will be changed to DocumentFieldAwareInterface in 2.0

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
29
    ViewDataFactoryInterface
30
{
31
    use FieldAwareTrait;
0 ignored issues
show
Deprecated Code introduced by
The trait ONGR\FilterManagerBundle...\Helper\FieldAwareTrait has been deprecated with message: FieldAwareTrait will be changed to DocumentFieldAwareTrait in 2.0

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
32
33
    /**
34
     * @var bool
35
     */
36
    private $inclusive = false;
37
38
    /**
39
     * @param bool $inclusive
40
     *
41
     * @return $this
42
     */
43
    public function setInclusive($inclusive)
44
    {
45
        $this->inclusive = $inclusive;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @return bool
52
     */
53
    public function isInclusive()
54
    {
55
        return $this->inclusive;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function createViewData()
62
    {
63
        return new RangeAwareViewData();
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 View Code Duplication
    public function modifySearch(Search $search, FilterState $state = null, SearchRequest $request = null)
70
    {
71
        if ($state && $state->isActive()) {
72
            $filter = new RangeQuery($this->getField(), $state->getValue());
73
            $search->addPostFilter($filter);
74
        }
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function isRelated()
81
    {
82
        return false;
83
    }
84
}
85