1 | <?php |
||
12 | class RestConfiguration |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $rootEndpoint = '/'; |
||
18 | |||
19 | /** |
||
20 | * Validator service for handling common validation tasks. |
||
21 | * |
||
22 | * @var Validator |
||
23 | */ |
||
24 | private $validator; |
||
25 | |||
26 | /** |
||
27 | * The configured API scheme, such as http or https. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private $scheme; |
||
32 | |||
33 | /** |
||
34 | * The configured API hostname. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | private $host; |
||
39 | |||
40 | /** |
||
41 | * Whether all relationship fields should be included by default. |
||
42 | * |
||
43 | * @var bool |
||
44 | */ |
||
45 | private $includeAll = true; |
||
46 | |||
47 | /** |
||
48 | * Determines how entity names should be formatted. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $entityFormat = 'dash'; |
||
53 | |||
54 | /** |
||
55 | * Determines how field key names should be formatted. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private $fieldKeyFormat = 'camelcase'; |
||
60 | |||
61 | /** |
||
62 | * Constructor. |
||
63 | * |
||
64 | * @param Validator|null $validator |
||
65 | */ |
||
66 | public function __construct(Validator $validator = null) |
||
70 | |||
71 | /** |
||
72 | * Gets the validator service. |
||
73 | * |
||
74 | * @return Validator |
||
75 | */ |
||
76 | public function getValidator() |
||
80 | |||
81 | /** |
||
82 | * Gets the root API endpoint shared by all requests. |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getRootEndpoint() |
||
90 | |||
91 | /** |
||
92 | * Sets the root API endpoint shared by all requests. |
||
93 | * |
||
94 | * @param string $endpoint |
||
95 | * @return self |
||
96 | */ |
||
97 | public function setRootEndpoint($endpoint) |
||
102 | |||
103 | /** |
||
104 | * Sets the entity type format. |
||
105 | * |
||
106 | * @param string $format |
||
107 | * @return self |
||
108 | */ |
||
109 | public function setEntityFormat($format) |
||
115 | |||
116 | /** |
||
117 | * Gets the entity type format. |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | public function getEntityFormat() |
||
125 | |||
126 | /** |
||
127 | * Sets the field key format. |
||
128 | * |
||
129 | * @param string $format |
||
130 | * @return self |
||
131 | */ |
||
132 | public function setFieldKeyFormat($format) |
||
138 | |||
139 | /** |
||
140 | * Gets the field key format. |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | public function getFieldKeyFormat() |
||
148 | |||
149 | /** |
||
150 | * Sets the scheme for all API requests. |
||
151 | * |
||
152 | * @param string $scheme |
||
153 | * @return self |
||
154 | */ |
||
155 | public function setScheme($scheme) |
||
160 | |||
161 | /** |
||
162 | * Gets the scheme for all API requests. |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | public function getScheme() |
||
170 | |||
171 | /** |
||
172 | * Sets the hostname for all API requests. |
||
173 | * |
||
174 | * @param string $host |
||
175 | * @return self |
||
176 | */ |
||
177 | public function setHost($host) |
||
182 | |||
183 | /** |
||
184 | * Gets the hostname for all API requests. |
||
185 | * |
||
186 | * @return string |
||
187 | */ |
||
188 | public function getHost() |
||
192 | |||
193 | /** |
||
194 | * Whether all relationships should be included (side-loaded) by default. |
||
195 | * |
||
196 | * @param bool |
||
197 | */ |
||
198 | public function includeAllByDefault() |
||
202 | |||
203 | /** |
||
204 | * Gets the default pagination criteria. |
||
205 | * |
||
206 | * @return array |
||
207 | */ |
||
208 | public function getDefaultPagination() |
||
215 | |||
216 | /** |
||
217 | * Gets the default sorting criteria. |
||
218 | * |
||
219 | * @return array |
||
220 | */ |
||
221 | public function getDefaultSorting() |
||
225 | } |
||
226 |