|
@@ -0,0 +1,113 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+namespace Muzich\CoreBundle\Searcher;
|
|
4
|
+
|
|
5
|
+class ElementSearcher extends Searcher implements SearcherInterface
|
|
6
|
+{
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+ * Constante définissant si la recherche porte sur le réseau public
|
|
10
|
+ * ou sur le réseau personel de l'utilisateur.
|
|
11
|
+ */
|
|
12
|
+ const NETWORK_PUBLIC = 'network_public';
|
|
13
|
+ const NETWORK_PERSONAL = 'network_personal';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+ * Réseau sur lequel porte la recherche
|
|
17
|
+ *
|
|
18
|
+ * @var string
|
|
19
|
+ */
|
|
20
|
+ protected $network = self::NETWORK_PUBLIC;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+ * Liste des tags utilisés lors de la recherche.
|
|
24
|
+ *
|
|
25
|
+ * @var array
|
|
26
|
+ */
|
|
27
|
+ protected $tags = Array();
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+ * Nombre limite de résultats retournés.
|
|
31
|
+ * TODO: Placer cette info dans la config.
|
|
32
|
+ *
|
|
33
|
+ * @var int
|
|
34
|
+ */
|
|
35
|
+ protected $count = 20;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+ * Objet requete
|
|
39
|
+ *
|
|
40
|
+ * @var
|
|
41
|
+ */
|
|
42
|
+ protected $query = null;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+ * Liste des Element Résultats
|
|
46
|
+ *
|
|
47
|
+ * @var array
|
|
48
|
+ */
|
|
49
|
+ protected $results = array();
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+ * @see SearcherInterface
|
|
53
|
+ * @param array $params
|
|
54
|
+ */
|
|
55
|
+ public function init($params)
|
|
56
|
+ {
|
|
57
|
+
|
|
58
|
+ $this->checkParams($params, array(
|
|
59
|
+ 'tags' => "Muzich\CoreBundle\Searcher\ElementSearch::init(): \$params: Au moins un tag est nécéssaire"
|
|
60
|
+ ));
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+ $this->setAttributes(array(
|
|
64
|
+ 'network', 'tags', 'count'
|
|
65
|
+ ), $params);
|
|
66
|
+
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+ * @see SearcherInterface
|
|
71
|
+ * @param array $params
|
|
72
|
+ */
|
|
73
|
+ public function update($params)
|
|
74
|
+ {
|
|
75
|
+
|
|
76
|
+ $this->setAttributes(array(
|
|
77
|
+ 'network', 'tags', 'count'
|
|
78
|
+ ), $params);
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+ * @see SearcherInterface
|
|
83
|
+ */
|
|
84
|
+ public function constructQueryObject()
|
|
85
|
+ {
|
|
86
|
+
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+ * @see SearcherInterface
|
|
91
|
+ * @return
|
|
92
|
+ */
|
|
93
|
+ public function getQueryObject()
|
|
94
|
+ {
|
|
95
|
+ if (!$this->query)
|
|
96
|
+ {
|
|
97
|
+ $this->constructQueryObject();
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ return $this->query;
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ public function getResults()
|
|
104
|
+ {
|
|
105
|
+ if (!$this->query)
|
|
106
|
+ {
|
|
107
|
+ $this->constructQueryObject();
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+ }
|
|
112
|
+
|
|
113
|
+}
|