|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fmaj\LaposteDatanovaBundle\Model; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @author Florian Ajir <[email protected]> |
|
9
|
|
|
*/ |
|
10
|
|
|
abstract class Parameters extends ParameterBag |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* {@inheritdoc} |
|
14
|
|
|
*/ |
|
15
|
5 |
|
public function __construct(array $parameters = array()) |
|
16
|
|
|
{ |
|
17
|
5 |
|
parent::__construct($parameters); |
|
18
|
5 |
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @return array |
|
22
|
|
|
*/ |
|
23
|
2 |
|
public function getParameters() |
|
24
|
|
|
{ |
|
25
|
2 |
|
return $this->parameters; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @return string $query |
|
30
|
|
|
*/ |
|
31
|
1 |
|
public function getFilter() |
|
32
|
|
|
{ |
|
33
|
1 |
|
return $this->get('q'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param string $query |
|
38
|
|
|
* |
|
39
|
|
|
* @return $this |
|
40
|
|
|
*/ |
|
41
|
1 |
|
public function setFilter($query) |
|
42
|
|
|
{ |
|
43
|
1 |
|
$this->set('q', $query); |
|
44
|
|
|
|
|
45
|
1 |
|
return $this; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param $lang |
|
50
|
|
|
* |
|
51
|
|
|
* @return self |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function setLang($lang) |
|
54
|
|
|
{ |
|
55
|
1 |
|
$this->set('lang', $lang); |
|
56
|
|
|
|
|
57
|
1 |
|
return $this; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function getLang() |
|
64
|
|
|
{ |
|
65
|
1 |
|
return $this->get('lang'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Get column prefix of a query |
|
70
|
|
|
* |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
1 |
|
public function getFilterColumn() |
|
74
|
|
|
{ |
|
75
|
1 |
|
$column = null; |
|
76
|
1 |
|
$filterAssoc = $this->explodeFilter(); |
|
77
|
1 |
|
if (isset($filterAssoc[0])) { |
|
78
|
1 |
|
$column = $filterAssoc[0]; |
|
79
|
1 |
|
} |
|
80
|
|
|
|
|
81
|
1 |
|
return $column; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return array |
|
86
|
|
|
*/ |
|
87
|
1 |
|
protected function explodeFilter() |
|
88
|
|
|
{ |
|
89
|
1 |
|
$explode = array(); |
|
90
|
1 |
|
$query = $this->get('q'); |
|
91
|
1 |
|
if (null !== $query) { |
|
92
|
1 |
|
if (false !== strpos($query, ':')) { |
|
93
|
1 |
|
$explode = explode(':', $query); |
|
94
|
1 |
|
} elseif (false !== strpos($query, '=')) { |
|
95
|
1 |
|
$explode = explode('=', $query); |
|
96
|
1 |
|
} |
|
97
|
1 |
|
} |
|
98
|
|
|
|
|
99
|
1 |
|
return $explode; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return string |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function getFilterValue() |
|
106
|
|
|
{ |
|
107
|
1 |
|
$value = $this->get('q'); |
|
108
|
1 |
|
$filterAssoc = $this->explodeFilter(); |
|
109
|
1 |
|
if (isset($filterAssoc[1])) { |
|
110
|
1 |
|
$value = $filterAssoc[1]; |
|
111
|
1 |
|
} |
|
112
|
|
|
|
|
113
|
1 |
|
return $value; |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|