|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* soluble-flexstore library |
|
5
|
|
|
* |
|
6
|
|
|
* @author Vanvelthem Sébastien |
|
7
|
|
|
* @link https://github.com/belgattitude/soluble-flexstore |
|
8
|
|
|
* @copyright Copyright (c) 2016-2017 Vanvelthem Sébastien |
|
9
|
|
|
* @license MIT License https://github.com/belgattitude/soluble-flexstore/blob/master/LICENSE.md |
|
10
|
|
|
* |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Soluble\FlexStore\Options; |
|
14
|
|
|
|
|
15
|
|
|
class HydrationOptions |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var array |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $params = []; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $default_params = [ |
|
26
|
|
|
'disable_formatters' => false, |
|
27
|
|
|
'disable_renderers' => false, |
|
28
|
|
|
'disable_column_exclusion' => false |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
41 |
|
public function __construct() |
|
32
|
|
|
{ |
|
33
|
41 |
|
$this->params = $this->default_params; |
|
34
|
41 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Disable formatters processing when getting data. |
|
38
|
|
|
* |
|
39
|
|
|
* @return HydrationOptions |
|
40
|
|
|
*/ |
|
41
|
17 |
|
public function disableFormatters() |
|
42
|
|
|
{ |
|
43
|
17 |
|
$this->params['disable_formatters'] = true; |
|
44
|
|
|
|
|
45
|
17 |
|
return $this; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Enable formatters processing when getting data. |
|
50
|
|
|
* |
|
51
|
|
|
* @return HydrationOptions |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function enableFormatters() |
|
54
|
|
|
{ |
|
55
|
1 |
|
$this->params['disable_formatters'] = false; |
|
56
|
|
|
|
|
57
|
1 |
|
return $this; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Test chether formatters should be called when getting data. |
|
62
|
|
|
* |
|
63
|
|
|
* @return bool |
|
64
|
|
|
*/ |
|
65
|
10 |
|
public function isFormattersEnabled() |
|
66
|
|
|
{ |
|
67
|
10 |
|
return $this->params['disable_formatters'] == false; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Disable renderers processing when getting data. |
|
72
|
|
|
* |
|
73
|
|
|
* @return HydrationOptions |
|
74
|
|
|
*/ |
|
75
|
1 |
|
public function disableRenderers() |
|
76
|
|
|
{ |
|
77
|
1 |
|
$this->params['disable_renderers'] = true; |
|
78
|
|
|
|
|
79
|
1 |
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Enable renderers processing when getting data. |
|
84
|
|
|
* |
|
85
|
|
|
* @return HydrationOptions |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function enableRenderers() |
|
88
|
|
|
{ |
|
89
|
1 |
|
$this->params['disable_renderers'] = false; |
|
90
|
|
|
|
|
91
|
1 |
|
return $this; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Test whether renderers should be called when getting data. |
|
96
|
|
|
* |
|
97
|
|
|
* @return bool |
|
98
|
|
|
*/ |
|
99
|
10 |
|
public function isRenderersEnabled() |
|
100
|
|
|
{ |
|
101
|
10 |
|
return $this->params['disable_renderers'] == false; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Disable column exclusion when getting data. |
|
106
|
|
|
* |
|
107
|
|
|
* @return HydrationOptions |
|
108
|
|
|
*/ |
|
109
|
1 |
|
public function disableColumnExclusion() |
|
110
|
|
|
{ |
|
111
|
1 |
|
$this->params['disable_column_exclusion'] = true; |
|
112
|
|
|
|
|
113
|
1 |
|
return $this; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Enable column exclusion when getting data. |
|
118
|
|
|
* |
|
119
|
|
|
* @return HydrationOptions |
|
120
|
|
|
*/ |
|
121
|
1 |
|
public function enableColumnExclusion() |
|
122
|
|
|
{ |
|
123
|
1 |
|
$this->params['disable_column_exclusion'] = false; |
|
124
|
|
|
|
|
125
|
1 |
|
return $this; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Test whether column model exclusions are enabled. |
|
130
|
|
|
* |
|
131
|
|
|
* @return bool |
|
132
|
|
|
*/ |
|
133
|
10 |
|
public function isColumnExclusionEnabled() |
|
134
|
|
|
{ |
|
135
|
10 |
|
return $this->params['disable_column_exclusion'] == false; |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|