|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Schema Class for output data. |
|
4
|
|
|
*/ |
|
5
|
|
|
namespace Graviton\AnalyticsBundle\Model; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Schema |
|
9
|
|
|
* |
|
10
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
|
11
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
12
|
|
|
* @link http://swisscom.ch |
|
13
|
|
|
*/ |
|
14
|
|
|
class AnalyticModel |
|
15
|
|
|
{ |
|
16
|
|
|
protected $collection; |
|
17
|
|
|
protected $route; |
|
18
|
|
|
protected $aggregate; |
|
19
|
|
|
protected $pipeline; |
|
20
|
|
|
protected $schema; |
|
21
|
|
|
protected $type; |
|
22
|
|
|
protected $cacheTime; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* String collection |
|
26
|
|
|
* @return mixed |
|
27
|
|
|
*/ |
|
28
|
|
|
public function getCollection() |
|
29
|
|
|
{ |
|
30
|
|
|
return $this->collection; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Set value of collection |
|
35
|
|
|
* @param mixed $collection string name |
|
36
|
|
|
* @return void |
|
37
|
|
|
*/ |
|
38
|
|
|
public function setCollection($collection) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->collection = $collection; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Route path |
|
45
|
|
|
* @return mixed |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getRoute() |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->route; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Set path |
|
54
|
|
|
* @param mixed $route string route |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
|
|
public function setRoute($route) |
|
58
|
|
|
{ |
|
59
|
|
|
$this->route = $route; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Mongodb Aggregates |
|
64
|
|
|
* @return mixed |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getAggregate() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->aggregate ?: []; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Set mongodb query |
|
73
|
|
|
* @param mixed $aggregate object type for query data |
|
74
|
|
|
* @return void |
|
75
|
|
|
*/ |
|
76
|
|
|
public function setAggregate($aggregate) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->aggregate = $aggregate; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return mixed |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getPipeline() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->pipeline ?: []; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param mixed $pipeline Data array for query |
|
91
|
|
|
* @return void |
|
92
|
|
|
*/ |
|
93
|
|
|
public function setPipeline($pipeline) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->pipeline = $pipeline; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Schema for response |
|
100
|
|
|
* @return mixed |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getSchema() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->schema; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Schema data |
|
109
|
|
|
* @param mixed $schema object schema |
|
110
|
|
|
* @return void |
|
111
|
|
|
*/ |
|
112
|
|
|
public function setSchema($schema) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->schema = $schema; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Type of response data |
|
119
|
|
|
* @return mixed |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getType() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->type; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Type for representation |
|
128
|
|
|
* @param mixed $type string view |
|
129
|
|
|
* @return void |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setType($type) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->type = $type; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Time for this route data to be cached |
|
138
|
|
|
* @return mixed |
|
|
|
|
|
|
139
|
|
|
*/ |
|
140
|
|
|
public function getCacheTime() |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->cacheTime; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Time for this route data to be cached |
|
147
|
|
|
* @param integer $cacheTime seconds to be cached |
|
148
|
|
|
* @return void |
|
149
|
|
|
*/ |
|
150
|
|
|
public function setCacheTime($cacheTime) |
|
151
|
|
|
{ |
|
152
|
|
|
$this->cacheTime = (int) $cacheTime; |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.