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; |
13
|
|
|
|
14
|
|
|
use ONGR\FilterManagerBundle\Filter\FilterInterface; |
15
|
|
|
use ONGR\FilterManagerBundle\Filter\FilterState; |
16
|
|
|
use ONGR\FilterManagerBundle\Filter\Helper\DocumentFieldAwareTrait; |
17
|
|
|
use ONGR\FilterManagerBundle\Filter\Helper\OptionsAwareTrait; |
18
|
|
|
use ONGR\FilterManagerBundle\Filter\Helper\RequestFieldAwareTrait; |
19
|
|
|
use ONGR\FilterManagerBundle\Filter\Relation\RelationAwareTrait; |
20
|
|
|
use Symfony\Component\HttpFoundation\Request; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* This class generalises filters using single field value from request. |
24
|
|
|
* |
25
|
|
|
* @deprecated Will be renamed to AbstractFilter. |
26
|
|
|
*/ |
27
|
|
|
abstract class AbstractFilter implements FilterInterface |
28
|
|
|
{ |
29
|
|
|
use RelationAwareTrait; |
30
|
|
|
use RequestFieldAwareTrait; |
31
|
|
|
use DocumentFieldAwareTrait; |
|
|
|
|
32
|
|
|
use OptionsAwareTrait; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
private $tags = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
public function getState(Request $request) |
43
|
|
|
{ |
44
|
|
|
$state = new FilterState(); |
45
|
|
|
$value = $request->get($this->getRequestField()); |
46
|
|
|
|
47
|
|
|
if (isset($value) && $value !== '') { |
48
|
|
|
$value = is_array($value) ? array_values($value) : $value; |
49
|
|
|
$state->setActive(true); |
50
|
|
|
$state->setValue($value); |
51
|
|
|
$state->setUrlParameters([$this->getRequestField() => $value]); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $state; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return string |
60
|
|
|
*/ |
61
|
|
|
public function getTags() |
62
|
|
|
{ |
63
|
|
|
return $this->tags; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param string $tags |
68
|
|
|
*/ |
69
|
|
|
public function setTags($tags) |
70
|
|
|
{ |
71
|
|
|
$this->tags = $tags; |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
|
|
public function isRelated() |
78
|
|
|
{ |
79
|
|
|
return false; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
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.