|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Stinger Entity Search package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Oliver Kotte <[email protected]> |
|
7
|
|
|
* (c) Florian Meyer <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace StingerSoft\EntitySearchBundle\Model; |
|
13
|
|
|
|
|
14
|
|
|
class Query { |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
private $term; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* |
|
24
|
|
|
* @var string[string] |
|
25
|
|
|
*/ |
|
26
|
|
|
private $facets = array(); |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* |
|
30
|
|
|
* @var string[] |
|
31
|
|
|
*/ |
|
32
|
|
|
private $usedFacets = null; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $term |
|
37
|
|
|
* @param string[string] $facets |
|
|
|
|
|
|
38
|
|
|
* @param string[] $usedFacets |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct($term = null, array $facets = array(), $usedFacets = null) { |
|
41
|
|
|
$this->term = $term; |
|
42
|
|
|
$this->facets = $facets; |
|
43
|
|
|
$this->usedFacets = $usedFacets; |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get the search term |
|
48
|
|
|
* |
|
49
|
|
|
* @return string Returns the search term |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getSearchTerm() { |
|
52
|
|
|
return $this->term; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* |
|
57
|
|
|
* @return string[string] |
|
|
|
|
|
|
58
|
|
|
*/ |
|
59
|
|
|
public function getFacets() { |
|
60
|
|
|
return $this->facets; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* |
|
65
|
|
|
* @return string[] |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getUsedFacets() { |
|
68
|
|
|
return $this->usedFacets; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function setSearchTerm($term) { |
|
72
|
|
|
$this->term = $term; |
|
73
|
|
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function setFacets($facets) { |
|
77
|
|
|
$this->facets = $facets; |
|
78
|
|
|
return $this; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function setUsedFacets($usedFacets) { |
|
82
|
|
|
$this->usedFacets = $usedFacets; |
|
83
|
|
|
return $this; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* |
|
88
|
|
|
* @param string $name |
|
89
|
|
|
* Name of the property to fetch |
|
90
|
|
|
* @return \Pec\Bundle\MtuDvpBundle\Entity\TestRiskValue |
|
91
|
|
|
*/ |
|
92
|
|
|
public function __get($name) { |
|
93
|
|
|
if(strrpos($name, 'facet_', -strlen($name)) !== false) { |
|
94
|
|
|
$facetname = substr($name, 6); |
|
95
|
|
|
|
|
96
|
|
|
if(isset($this->facets[$facetname])) { |
|
97
|
|
|
return $this->facets[$facetname]; |
|
98
|
|
|
} |
|
99
|
|
|
return array(); |
|
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* |
|
105
|
|
|
* @param string $name |
|
106
|
|
|
* Name of the property to set |
|
107
|
|
|
* @param mixed $value |
|
108
|
|
|
* The value of the property |
|
109
|
|
|
*/ |
|
110
|
|
|
public function __set($name, $value) { |
|
111
|
|
|
if(strrpos($name, 'facet_', -strlen($name)) !== false) { |
|
112
|
|
|
$facetname = substr($name, 6); |
|
113
|
|
|
|
|
114
|
|
|
if(isset($this->facets[$facetname])) { |
|
115
|
|
|
$this->facets[$facetname] = array(); |
|
116
|
|
|
} |
|
117
|
|
|
$this->facets[$facetname] = $value; |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Checks whether the given property is set or not |
|
123
|
|
|
* |
|
124
|
|
|
* @param string $name |
|
125
|
|
|
* @return boolean |
|
126
|
|
|
*/ |
|
127
|
|
|
public function __isset($name) { |
|
128
|
|
|
if(strrpos($name, 'facet_', -strlen($name)) !== false) { |
|
129
|
|
|
return true; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
return false; |
|
133
|
|
|
} |
|
134
|
|
|
} |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.