@@ -50,7 +50,6 @@ |
||
50 | 50 | /** |
51 | 51 | * Constructs new instance of SQLSrverExpressionProvider for NorthWind DB |
52 | 52 | * |
53 | - * @param string $iterName The name of the iterator |
|
54 | 53 | */ |
55 | 54 | public function __construct() |
56 | 55 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function getIteratorName() |
65 | 65 | { |
66 | - return null; |
|
66 | + return null; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function setResourceType(ResourceType $resourceType) |
76 | 76 | { |
77 | - $this->_resourceType = $resourceType; |
|
77 | + $this->_resourceType = $resourceType; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -225,66 +225,66 @@ discard block |
||
225 | 225 | $variable = null; |
226 | 226 | $isFirstLevelPrimitive = is_null($parent->getParent()); |
227 | 227 | if (!$isFirstLevelPrimitive) { |
228 | - // This propery access sub-expression in the $filter need access |
|
229 | - // to level 2 or greater property of a complex or resource reference |
|
230 | - // property. |
|
231 | - // e.g. Customers?$filter=Address/City eq 'Kottayam' |
|
232 | - // Level_2 property access [Complex] |
|
233 | - // Customers?$filter=Address/AltAddress/City eq 'Seattle' |
|
234 | - // Level_3 property access [Complex] |
|
235 | - // Orders?$filter=Customer/CustomerID eq 'ALFKI' |
|
236 | - // Level_2 property access [Resource Reference] |
|
237 | - $parent2 = null; |
|
238 | - do { |
|
239 | - $parent2 = $parent; |
|
240 | - $parent = $parent->getParent(); |
|
241 | - } while ($parent != null); |
|
228 | + // This propery access sub-expression in the $filter need access |
|
229 | + // to level 2 or greater property of a complex or resource reference |
|
230 | + // property. |
|
231 | + // e.g. Customers?$filter=Address/City eq 'Kottayam' |
|
232 | + // Level_2 property access [Complex] |
|
233 | + // Customers?$filter=Address/AltAddress/City eq 'Seattle' |
|
234 | + // Level_3 property access [Complex] |
|
235 | + // Orders?$filter=Customer/CustomerID eq 'ALFKI' |
|
236 | + // Level_2 property access [Resource Reference] |
|
237 | + $parent2 = null; |
|
238 | + do { |
|
239 | + $parent2 = $parent; |
|
240 | + $parent = $parent->getParent(); |
|
241 | + } while ($parent != null); |
|
242 | 242 | |
243 | - $resourceProperty = $parent2->getResourceProperty(); |
|
244 | - if ($resourceProperty->isKindOf(ResourcePropertyKind::RESOURCE_REFERENCE)) { |
|
245 | - // Orders?$filter=Customer/CustomerID eq 'ALFKI' |
|
246 | - throw new NotImplementedException( |
|
247 | - 'This implementation not supports Resource reference in the filter', |
|
248 | - 500, |
|
249 | - NULL |
|
250 | - ); |
|
251 | - } else { |
|
252 | - // Customers?$filter=Address/AltAddress/City eq 'Seattle' |
|
253 | - // Customers?$filter=Address/City eq 'Seattle' |
|
254 | - $propertyName = $parent2->getResourceProperty()->getName(); |
|
255 | - if ("Address" == $propertyName) { |
|
256 | - $child = $parent2->getChild(); |
|
257 | - $propertyName = $child->getResourceProperty()->getName(); |
|
258 | - if ("AltAddress" != $propertyName) { |
|
259 | - return $propertyName; |
|
260 | - } |
|
243 | + $resourceProperty = $parent2->getResourceProperty(); |
|
244 | + if ($resourceProperty->isKindOf(ResourcePropertyKind::RESOURCE_REFERENCE)) { |
|
245 | + // Orders?$filter=Customer/CustomerID eq 'ALFKI' |
|
246 | + throw new NotImplementedException( |
|
247 | + 'This implementation not supports Resource reference in the filter', |
|
248 | + 500, |
|
249 | + NULL |
|
250 | + ); |
|
251 | + } else { |
|
252 | + // Customers?$filter=Address/AltAddress/City eq 'Seattle' |
|
253 | + // Customers?$filter=Address/City eq 'Seattle' |
|
254 | + $propertyName = $parent2->getResourceProperty()->getName(); |
|
255 | + if ("Address" == $propertyName) { |
|
256 | + $child = $parent2->getChild(); |
|
257 | + $propertyName = $child->getResourceProperty()->getName(); |
|
258 | + if ("AltAddress" != $propertyName) { |
|
259 | + return $propertyName; |
|
260 | + } |
|
261 | 261 | |
262 | - throw new NotImplementedException( |
|
263 | - 'This implementation not supports Customer::Address::AltAddress in the filter', |
|
264 | - 500, |
|
265 | - NULL |
|
266 | - ); |
|
267 | - } |
|
268 | - } |
|
262 | + throw new NotImplementedException( |
|
263 | + 'This implementation not supports Customer::Address::AltAddress in the filter', |
|
264 | + 500, |
|
265 | + NULL |
|
266 | + ); |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | 270 | } else { |
271 | - // This is a first level property access |
|
272 | - $resourceProperty = $parent->getResourceProperty(); |
|
273 | - if ($resourceProperty->isKindOf(ResourcePropertyKind::COMPLEX_TYPE) |
|
274 | - || $resourceProperty->isKindOf(ResourcePropertyKind::RESOURCE_REFERENCE)) { |
|
275 | - // Customers?$filter=Address eq null |
|
276 | - // Orders?$filter=Customer ne null |
|
277 | - // First level property access to a complex or resource reference |
|
278 | - // which is not supported by $this [this implementation of IDSQP2] |
|
279 | - throw new NotImplementedException( |
|
271 | + // This is a first level property access |
|
272 | + $resourceProperty = $parent->getResourceProperty(); |
|
273 | + if ($resourceProperty->isKindOf(ResourcePropertyKind::COMPLEX_TYPE) |
|
274 | + || $resourceProperty->isKindOf(ResourcePropertyKind::RESOURCE_REFERENCE)) { |
|
275 | + // Customers?$filter=Address eq null |
|
276 | + // Orders?$filter=Customer ne null |
|
277 | + // First level property access to a complex or resource reference |
|
278 | + // which is not supported by $this [this implementation of IDSQP2] |
|
279 | + throw new NotImplementedException( |
|
280 | 280 | 'First level complex and Resource reference are not supported in the filter', |
281 | - 500, |
|
282 | - NULL |
|
281 | + 500, |
|
282 | + NULL |
|
283 | 283 | ); |
284 | - } else { |
|
285 | - // First level property access to primitive property |
|
286 | - return $parent->getResourceProperty()->getName(); |
|
287 | - } |
|
284 | + } else { |
|
285 | + // First level property access to primitive property |
|
286 | + return $parent->getResourceProperty()->getName(); |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | /** |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | case ODataConstants::STRFUN_SUBSTRING: |
331 | 331 | if (count($params) == 3) { |
332 | 332 | // 3 Param version of OData substring |
333 | - return "SUBSTRING($params[0], $params[1] + 1, $params[2])"; |
|
334 | - } else { |
|
333 | + return "SUBSTRING($params[0], $params[1] + 1, $params[2])"; |
|
334 | + } else { |
|
335 | 335 | // 2 Params version of OData substring |
336 | 336 | // We don't have the same function for SQL Server, we have only: |
337 | 337 | // |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | // in value_expression, the whole value expression beginning at start_expression is returned |
343 | 343 | // In OData substring function the index start from 0, in SQL Server its from 1 |
344 | 344 | return "SUBSTRING($params[0], $params[1] + 1, LEN($params[0]))"; |
345 | - } |
|
345 | + } |
|
346 | 346 | break; |
347 | 347 | case ODataConstants::STRFUN_SUBSTRINGOF: |
348 | 348 | return "(CHARINDEX($params[0], $params[1]) != 0)"; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | case ODataConstants::BINFUL_EQUAL: |
390 | 390 | return "($params[0] = $params[1])"; |
391 | 391 | break; |
392 | - case 'is_null': |
|
392 | + case 'is_null': |
|
393 | 393 | return "is_null($params[0])"; |
394 | 394 | break; |
395 | 395 | |
@@ -409,20 +409,20 @@ discard block |
||
409 | 409 | */ |
410 | 410 | private function _prepareBinaryExpression($operator, $left, $right) |
411 | 411 | { |
412 | - if (!substr_compare($left, "STRCMP", 0, 6)) { |
|
412 | + if (!substr_compare($left, "STRCMP", 0, 6)) { |
|
413 | 413 | $str = explode(';', $left, 2); |
414 | 414 | $str[0] = str_replace('STRCMP', '', $str[0]); |
415 | 415 | if ($right == 'false' and $right != '0') { |
416 | - if (!substr_compare($operator, '!', 0, 1)) { |
|
417 | - $operator = str_replace('!', '', $operator); |
|
418 | - } else if ($operator == '>=') { |
|
419 | - $operator = '<'; |
|
420 | - } else if ($operator == '<=') { |
|
421 | - $operator = '>'; |
|
422 | - } else { |
|
416 | + if (!substr_compare($operator, '!', 0, 1)) { |
|
417 | + $operator = str_replace('!', '', $operator); |
|
418 | + } else if ($operator == '>=') { |
|
419 | + $operator = '<'; |
|
420 | + } else if ($operator == '<=') { |
|
421 | + $operator = '>'; |
|
422 | + } else { |
|
423 | 423 | $operator = "!".$operator; |
424 | - } |
|
425 | - return self::OPEN_BRAKET |
|
424 | + } |
|
425 | + return self::OPEN_BRAKET |
|
426 | 426 | . $str[0] . ' ' . $operator |
427 | 427 | . ' ' . $str[1] . self::CLOSE_BRACKET; |
428 | 428 | } else { |
@@ -434,26 +434,26 @@ discard block |
||
434 | 434 | |
435 | 435 | //DATETIMECMP |
436 | 436 | if (!substr_compare($left, "DATETIMECMP", 0, 11)) { |
437 | - $str = explode(';', $left, 2); |
|
438 | - $str[0] = str_replace('DATETIMECMP', '', $str[0]); |
|
439 | - if ($right == 'false' and $right != '0') { |
|
437 | + $str = explode(';', $left, 2); |
|
438 | + $str[0] = str_replace('DATETIMECMP', '', $str[0]); |
|
439 | + if ($right == 'false' and $right != '0') { |
|
440 | 440 | if (!substr_compare($operator, '!', 0, 1)) { |
441 | - $operator = str_replace('!', '', $operator); |
|
441 | + $operator = str_replace('!', '', $operator); |
|
442 | 442 | } else if ($operator == '>=') { |
443 | - $operator = '<'; |
|
443 | + $operator = '<'; |
|
444 | 444 | } else if ($operator == '<=') { |
445 | - $operator = '>'; |
|
445 | + $operator = '>'; |
|
446 | 446 | } else { |
447 | - $operator = "!".$operator; |
|
447 | + $operator = "!".$operator; |
|
448 | 448 | } |
449 | 449 | return self::OPEN_BRAKET |
450 | 450 | . $str[0] . ' ' . $operator |
451 | 451 | . ' ' . $str[1] . self::CLOSE_BRACKET; |
452 | - } else { |
|
452 | + } else { |
|
453 | 453 | return self::OPEN_BRAKET |
454 | 454 | . $str[0] . ' ' . $operator |
455 | 455 | . ' ' . $str[1] . self::CLOSE_BRACKET; |
456 | - } |
|
456 | + } |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | return |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | public function onLogicalExpression($expressionType, $left, $right) |
90 | 90 | { |
91 | 91 | switch($expressionType) { |
92 | - case ExpressionType::AND_LOGICAL: |
|
93 | - return $this->_prepareBinaryExpression(self::LOGICAL_AND, $left, $right); |
|
94 | - break; |
|
95 | - case ExpressionType::OR_LOGICAL: |
|
96 | - return $this->_prepareBinaryExpression(self::LOGICAL_OR, $left, $right); |
|
97 | - break; |
|
98 | - default: |
|
99 | - throw new \InvalidArgumentException('onLogicalExpression'); |
|
92 | + case ExpressionType::AND_LOGICAL: |
|
93 | + return $this->_prepareBinaryExpression(self::LOGICAL_AND, $left, $right); |
|
94 | + break; |
|
95 | + case ExpressionType::OR_LOGICAL: |
|
96 | + return $this->_prepareBinaryExpression(self::LOGICAL_OR, $left, $right); |
|
97 | + break; |
|
98 | + default: |
|
99 | + throw new \InvalidArgumentException('onLogicalExpression'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | public function onArithmeticExpression($expressionType, $left, $right) |
113 | 113 | { |
114 | 114 | switch($expressionType) { |
115 | - case ExpressionType::MULTIPLY: |
|
116 | - return $this->_prepareBinaryExpression(self::MULTIPLY, $left, $right); |
|
117 | - break; |
|
118 | - case ExpressionType::DIVIDE: |
|
119 | - return $this->_prepareBinaryExpression(self::DIVIDE, $left, $right); |
|
120 | - break; |
|
121 | - case ExpressionType::MODULO: |
|
122 | - return $this->_prepareBinaryExpression(self::MODULO, $left, $right); |
|
123 | - break; |
|
124 | - case ExpressionType::ADD: |
|
125 | - return $this->_prepareBinaryExpression(self::ADD, $left, $right); |
|
126 | - break; |
|
127 | - case ExpressionType::SUBTRACT: |
|
128 | - return $this->_prepareBinaryExpression(self::SUBTRACT, $left, $right); |
|
129 | - break; |
|
130 | - default: |
|
131 | - throw new \InvalidArgumentException('onArithmeticExpression'); |
|
115 | + case ExpressionType::MULTIPLY: |
|
116 | + return $this->_prepareBinaryExpression(self::MULTIPLY, $left, $right); |
|
117 | + break; |
|
118 | + case ExpressionType::DIVIDE: |
|
119 | + return $this->_prepareBinaryExpression(self::DIVIDE, $left, $right); |
|
120 | + break; |
|
121 | + case ExpressionType::MODULO: |
|
122 | + return $this->_prepareBinaryExpression(self::MODULO, $left, $right); |
|
123 | + break; |
|
124 | + case ExpressionType::ADD: |
|
125 | + return $this->_prepareBinaryExpression(self::ADD, $left, $right); |
|
126 | + break; |
|
127 | + case ExpressionType::SUBTRACT: |
|
128 | + return $this->_prepareBinaryExpression(self::SUBTRACT, $left, $right); |
|
129 | + break; |
|
130 | + default: |
|
131 | + throw new \InvalidArgumentException('onArithmeticExpression'); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -144,30 +144,30 @@ discard block |
||
144 | 144 | public function onRelationalExpression($expressionType, $left, $right) |
145 | 145 | { |
146 | 146 | switch($expressionType) { |
147 | - case ExpressionType::GREATERTHAN: |
|
148 | - return $this->_prepareBinaryExpression(self::GREATERTHAN, $left, $right); |
|
149 | - break; |
|
150 | - case ExpressionType::GREATERTHAN_OR_EQUAL: |
|
151 | - return $this->_prepareBinaryExpression( |
|
152 | - self::GREATERTHAN_OR_EQUAL, $left, $right |
|
153 | - ); |
|
154 | - break; |
|
155 | - case ExpressionType::LESSTHAN: |
|
156 | - return $this->_prepareBinaryExpression(self::LESSTHAN, $left, $right); |
|
157 | - break; |
|
158 | - case ExpressionType::LESSTHAN_OR_EQUAL: |
|
159 | - return $this->_prepareBinaryExpression( |
|
160 | - self::LESSTHAN_OR_EQUAL, $left, $right |
|
161 | - ); |
|
162 | - break; |
|
163 | - case ExpressionType::EQUAL: |
|
164 | - return $this->_prepareBinaryExpression(self::EQUAL, $left, $right); |
|
165 | - break; |
|
166 | - case ExpressionType::NOTEQUAL: |
|
167 | - return $this->_prepareBinaryExpression(self::NOTEQUAL, $left, $right); |
|
168 | - break; |
|
169 | - default: |
|
170 | - throw new \InvalidArgumentException('onArithmeticExpression'); |
|
147 | + case ExpressionType::GREATERTHAN: |
|
148 | + return $this->_prepareBinaryExpression(self::GREATERTHAN, $left, $right); |
|
149 | + break; |
|
150 | + case ExpressionType::GREATERTHAN_OR_EQUAL: |
|
151 | + return $this->_prepareBinaryExpression( |
|
152 | + self::GREATERTHAN_OR_EQUAL, $left, $right |
|
153 | + ); |
|
154 | + break; |
|
155 | + case ExpressionType::LESSTHAN: |
|
156 | + return $this->_prepareBinaryExpression(self::LESSTHAN, $left, $right); |
|
157 | + break; |
|
158 | + case ExpressionType::LESSTHAN_OR_EQUAL: |
|
159 | + return $this->_prepareBinaryExpression( |
|
160 | + self::LESSTHAN_OR_EQUAL, $left, $right |
|
161 | + ); |
|
162 | + break; |
|
163 | + case ExpressionType::EQUAL: |
|
164 | + return $this->_prepareBinaryExpression(self::EQUAL, $left, $right); |
|
165 | + break; |
|
166 | + case ExpressionType::NOTEQUAL: |
|
167 | + return $this->_prepareBinaryExpression(self::NOTEQUAL, $left, $right); |
|
168 | + break; |
|
169 | + default: |
|
170 | + throw new \InvalidArgumentException('onArithmeticExpression'); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | public function onUnaryExpression($expressionType, $child) |
183 | 183 | { |
184 | 184 | switch($expressionType) { |
185 | - case ExpressionType::NEGATE: |
|
186 | - return $this->_prepareUnaryExpression(self::NEGATE, $child); |
|
187 | - break; |
|
188 | - case ExpressionType::NOT_LOGICAL: |
|
189 | - return $this->_prepareUnaryExpression(self::LOGICAL_NOT, $child); |
|
190 | - break; |
|
191 | - default: |
|
192 | - throw new \InvalidArgumentException('onUnaryExpression'); |
|
185 | + case ExpressionType::NEGATE: |
|
186 | + return $this->_prepareUnaryExpression(self::NEGATE, $child); |
|
187 | + break; |
|
188 | + case ExpressionType::NOT_LOGICAL: |
|
189 | + return $this->_prepareUnaryExpression(self::LOGICAL_NOT, $child); |
|
190 | + break; |
|
191 | + default: |
|
192 | + throw new \InvalidArgumentException('onUnaryExpression'); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -298,103 +298,103 @@ discard block |
||
298 | 298 | public function onFunctionCallExpression($functionDescription, $params) |
299 | 299 | { |
300 | 300 | switch($functionDescription->functionName) { |
301 | - case ODataConstants::STRFUN_COMPARE: |
|
302 | - return "STRCMP($params[0]; $params[1])"; |
|
303 | - break; |
|
304 | - case ODataConstants::STRFUN_ENDSWITH: |
|
305 | - return "(($params[1]) = RIGHT(($params[0]), LEN($params[1])))"; |
|
306 | - break; |
|
307 | - case ODataConstants::STRFUN_INDEXOF: |
|
308 | - // In SQLServer the index of string starts from 1, but in OData |
|
309 | - // the string start with index 0, so the below subtraction of 1 |
|
310 | - return "(CHARINDEX($params[1], $params[0]) - 1)"; |
|
311 | - break; |
|
312 | - case ODataConstants::STRFUN_REPLACE: |
|
313 | - return "REPLACE($params[0], $params[1], $params[2])"; |
|
314 | - break; |
|
315 | - case ODataConstants::STRFUN_STARTSWITH: |
|
316 | - return "(($params[1]) = LEFT(($params[0]), LEN($params[1])))"; |
|
317 | - break; |
|
318 | - case ODataConstants::STRFUN_TOLOWER: |
|
319 | - return "LOWER($params[0])"; |
|
320 | - break; |
|
321 | - case ODataConstants::STRFUN_TOUPPER: |
|
322 | - return "UPPER($params[0])"; |
|
323 | - break; |
|
324 | - case ODataConstants::STRFUN_TRIM: |
|
325 | - // OData supports trim function |
|
326 | - // We don't have the same function SQL Server, so use SQL functions LTRIM and RTRIM together |
|
327 | - // to achieve TRIM functionality. |
|
328 | - return "RTRIM(LTRIM($params[0]))"; |
|
329 | - break; |
|
330 | - case ODataConstants::STRFUN_SUBSTRING: |
|
331 | - if (count($params) == 3) { |
|
332 | - // 3 Param version of OData substring |
|
333 | - return "SUBSTRING($params[0], $params[1] + 1, $params[2])"; |
|
334 | - } else { |
|
335 | - // 2 Params version of OData substring |
|
336 | - // We don't have the same function for SQL Server, we have only: |
|
337 | - // |
|
338 | - // SUBSTRING ( value_expression , start_expression , length_expression ) |
|
339 | - // http://msdn.microsoft.com/en-us/library/ms187748.aspx |
|
340 | - // |
|
341 | - // If the sum of start_expression and length_expression is greater than the number of characters |
|
342 | - // in value_expression, the whole value expression beginning at start_expression is returned |
|
343 | - // In OData substring function the index start from 0, in SQL Server its from 1 |
|
344 | - return "SUBSTRING($params[0], $params[1] + 1, LEN($params[0]))"; |
|
345 | - } |
|
346 | - break; |
|
347 | - case ODataConstants::STRFUN_SUBSTRINGOF: |
|
348 | - return "(CHARINDEX($params[0], $params[1]) != 0)"; |
|
349 | - break; |
|
350 | - case ODataConstants::STRFUN_CONCAT: |
|
351 | - return "$params[0] + $params[1]"; |
|
352 | - break; |
|
353 | - case ODataConstants::STRFUN_LENGTH: |
|
354 | - return "LEN($params[0])"; |
|
355 | - break; |
|
356 | - case ODataConstants::GUIDFUN_EQUAL: |
|
357 | - return "($params[0] = $params[1])"; |
|
358 | - break; |
|
359 | - case ODataConstants::DATETIME_COMPARE: |
|
360 | - return "DATETIMECMP($params[0]; $params[1])"; |
|
361 | - break; |
|
362 | - case ODataConstants::DATETIME_YEAR: |
|
363 | - return "YEAR($params[0])"; |
|
364 | - break; |
|
365 | - case ODataConstants::DATETIME_MONTH: |
|
366 | - return "MONTH($params[0])"; |
|
367 | - break; |
|
368 | - case ODataConstants::DATETIME_DAY: |
|
369 | - return "DAY($params[0])"; |
|
370 | - break; |
|
371 | - case ODataConstants::DATETIME_HOUR: |
|
372 | - return "DATENAME(HOUR, $params[0])"; |
|
373 | - break; |
|
374 | - case ODataConstants::DATETIME_MINUTE: |
|
375 | - return "DATENAME(MINUTE, $params[0])"; |
|
376 | - break; |
|
377 | - case ODataConstants::DATETIME_SECOND: |
|
378 | - return "DATENAME(SECOND, $params[0])"; |
|
379 | - break; |
|
380 | - case ODataConstants::MATHFUN_ROUND: |
|
381 | - return "ROUND($params[0], $this->_default_round)"; |
|
382 | - break; |
|
383 | - case ODataConstants::MATHFUN_CEILING: |
|
384 | - return "CEILING($params[0])"; |
|
385 | - break; |
|
386 | - case ODataConstants::MATHFUN_FLOOR: |
|
387 | - return "FLOOR($params[0])"; |
|
388 | - break; |
|
389 | - case ODataConstants::BINFUL_EQUAL: |
|
390 | - return "($params[0] = $params[1])"; |
|
391 | - break; |
|
301 | + case ODataConstants::STRFUN_COMPARE: |
|
302 | + return "STRCMP($params[0]; $params[1])"; |
|
303 | + break; |
|
304 | + case ODataConstants::STRFUN_ENDSWITH: |
|
305 | + return "(($params[1]) = RIGHT(($params[0]), LEN($params[1])))"; |
|
306 | + break; |
|
307 | + case ODataConstants::STRFUN_INDEXOF: |
|
308 | + // In SQLServer the index of string starts from 1, but in OData |
|
309 | + // the string start with index 0, so the below subtraction of 1 |
|
310 | + return "(CHARINDEX($params[1], $params[0]) - 1)"; |
|
311 | + break; |
|
312 | + case ODataConstants::STRFUN_REPLACE: |
|
313 | + return "REPLACE($params[0], $params[1], $params[2])"; |
|
314 | + break; |
|
315 | + case ODataConstants::STRFUN_STARTSWITH: |
|
316 | + return "(($params[1]) = LEFT(($params[0]), LEN($params[1])))"; |
|
317 | + break; |
|
318 | + case ODataConstants::STRFUN_TOLOWER: |
|
319 | + return "LOWER($params[0])"; |
|
320 | + break; |
|
321 | + case ODataConstants::STRFUN_TOUPPER: |
|
322 | + return "UPPER($params[0])"; |
|
323 | + break; |
|
324 | + case ODataConstants::STRFUN_TRIM: |
|
325 | + // OData supports trim function |
|
326 | + // We don't have the same function SQL Server, so use SQL functions LTRIM and RTRIM together |
|
327 | + // to achieve TRIM functionality. |
|
328 | + return "RTRIM(LTRIM($params[0]))"; |
|
329 | + break; |
|
330 | + case ODataConstants::STRFUN_SUBSTRING: |
|
331 | + if (count($params) == 3) { |
|
332 | + // 3 Param version of OData substring |
|
333 | + return "SUBSTRING($params[0], $params[1] + 1, $params[2])"; |
|
334 | + } else { |
|
335 | + // 2 Params version of OData substring |
|
336 | + // We don't have the same function for SQL Server, we have only: |
|
337 | + // |
|
338 | + // SUBSTRING ( value_expression , start_expression , length_expression ) |
|
339 | + // http://msdn.microsoft.com/en-us/library/ms187748.aspx |
|
340 | + // |
|
341 | + // If the sum of start_expression and length_expression is greater than the number of characters |
|
342 | + // in value_expression, the whole value expression beginning at start_expression is returned |
|
343 | + // In OData substring function the index start from 0, in SQL Server its from 1 |
|
344 | + return "SUBSTRING($params[0], $params[1] + 1, LEN($params[0]))"; |
|
345 | + } |
|
346 | + break; |
|
347 | + case ODataConstants::STRFUN_SUBSTRINGOF: |
|
348 | + return "(CHARINDEX($params[0], $params[1]) != 0)"; |
|
349 | + break; |
|
350 | + case ODataConstants::STRFUN_CONCAT: |
|
351 | + return "$params[0] + $params[1]"; |
|
352 | + break; |
|
353 | + case ODataConstants::STRFUN_LENGTH: |
|
354 | + return "LEN($params[0])"; |
|
355 | + break; |
|
356 | + case ODataConstants::GUIDFUN_EQUAL: |
|
357 | + return "($params[0] = $params[1])"; |
|
358 | + break; |
|
359 | + case ODataConstants::DATETIME_COMPARE: |
|
360 | + return "DATETIMECMP($params[0]; $params[1])"; |
|
361 | + break; |
|
362 | + case ODataConstants::DATETIME_YEAR: |
|
363 | + return "YEAR($params[0])"; |
|
364 | + break; |
|
365 | + case ODataConstants::DATETIME_MONTH: |
|
366 | + return "MONTH($params[0])"; |
|
367 | + break; |
|
368 | + case ODataConstants::DATETIME_DAY: |
|
369 | + return "DAY($params[0])"; |
|
370 | + break; |
|
371 | + case ODataConstants::DATETIME_HOUR: |
|
372 | + return "DATENAME(HOUR, $params[0])"; |
|
373 | + break; |
|
374 | + case ODataConstants::DATETIME_MINUTE: |
|
375 | + return "DATENAME(MINUTE, $params[0])"; |
|
376 | + break; |
|
377 | + case ODataConstants::DATETIME_SECOND: |
|
378 | + return "DATENAME(SECOND, $params[0])"; |
|
379 | + break; |
|
380 | + case ODataConstants::MATHFUN_ROUND: |
|
381 | + return "ROUND($params[0], $this->_default_round)"; |
|
382 | + break; |
|
383 | + case ODataConstants::MATHFUN_CEILING: |
|
384 | + return "CEILING($params[0])"; |
|
385 | + break; |
|
386 | + case ODataConstants::MATHFUN_FLOOR: |
|
387 | + return "FLOOR($params[0])"; |
|
388 | + break; |
|
389 | + case ODataConstants::BINFUL_EQUAL: |
|
390 | + return "($params[0] = $params[1])"; |
|
391 | + break; |
|
392 | 392 | case 'is_null': |
393 | 393 | return "is_null($params[0])"; |
394 | 394 | break; |
395 | 395 | |
396 | - default: |
|
397 | - throw new \InvalidArgumentException('onFunctionCallExpression'); |
|
396 | + default: |
|
397 | + throw new \InvalidArgumentException('onFunctionCallExpression'); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function onLogicalExpression($expressionType, $left, $right) |
90 | 90 | { |
91 | - switch($expressionType) { |
|
91 | + switch ($expressionType) { |
|
92 | 92 | case ExpressionType::AND_LOGICAL: |
93 | 93 | return $this->_prepareBinaryExpression(self::LOGICAL_AND, $left, $right); |
94 | 94 | break; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function onArithmeticExpression($expressionType, $left, $right) |
113 | 113 | { |
114 | - switch($expressionType) { |
|
114 | + switch ($expressionType) { |
|
115 | 115 | case ExpressionType::MULTIPLY: |
116 | 116 | return $this->_prepareBinaryExpression(self::MULTIPLY, $left, $right); |
117 | 117 | break; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function onRelationalExpression($expressionType, $left, $right) |
145 | 145 | { |
146 | - switch($expressionType) { |
|
146 | + switch ($expressionType) { |
|
147 | 147 | case ExpressionType::GREATERTHAN: |
148 | 148 | return $this->_prepareBinaryExpression(self::GREATERTHAN, $left, $right); |
149 | 149 | break; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function onUnaryExpression($expressionType, $child) |
183 | 183 | { |
184 | - switch($expressionType) { |
|
184 | + switch ($expressionType) { |
|
185 | 185 | case ExpressionType::NEGATE: |
186 | 186 | return $this->_prepareUnaryExpression(self::NEGATE, $child); |
187 | 187 | break; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public function onFunctionCallExpression($functionDescription, $params) |
299 | 299 | { |
300 | - switch($functionDescription->functionName) { |
|
300 | + switch ($functionDescription->functionName) { |
|
301 | 301 | case ODataConstants::STRFUN_COMPARE: |
302 | 302 | return "STRCMP($params[0]; $params[1])"; |
303 | 303 | break; |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | $operator = "!".$operator; |
424 | 424 | } |
425 | 425 | return self::OPEN_BRAKET |
426 | - . $str[0] . ' ' . $operator |
|
427 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
426 | + . $str[0].' '.$operator |
|
427 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
428 | 428 | } else { |
429 | 429 | return self::OPEN_BRAKET |
430 | - . $str[0] . ' ' . $operator |
|
431 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
430 | + . $str[0].' '.$operator |
|
431 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
@@ -447,19 +447,19 @@ discard block |
||
447 | 447 | $operator = "!".$operator; |
448 | 448 | } |
449 | 449 | return self::OPEN_BRAKET |
450 | - . $str[0] . ' ' . $operator |
|
451 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
450 | + . $str[0].' '.$operator |
|
451 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
452 | 452 | } else { |
453 | 453 | return self::OPEN_BRAKET |
454 | - . $str[0] . ' ' . $operator |
|
455 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
454 | + . $str[0].' '.$operator |
|
455 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | 459 | return |
460 | 460 | self::OPEN_BRAKET |
461 | - . $left . ' ' . $operator |
|
462 | - . ' ' . $right . self::CLOSE_BRACKET; |
|
461 | + . $left.' '.$operator |
|
462 | + . ' '.$right.self::CLOSE_BRACKET; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -472,6 +472,6 @@ discard block |
||
472 | 472 | */ |
473 | 473 | private function _prepareUnaryExpression($operator, $child) |
474 | 474 | { |
475 | - return $operator . self::OPEN_BRAKET . $child . self::CLOSE_BRACKET; |
|
475 | + return $operator.self::OPEN_BRAKET.$child.self::CLOSE_BRACKET; |
|
476 | 476 | } |
477 | 477 | } |
@@ -172,7 +172,7 @@ |
||
172 | 172 | * |
173 | 173 | * @throws InvalidOperationException |
174 | 174 | * |
175 | - * @return NorthWindMetadata |
|
175 | + * @return SimpleMetadataProvider |
|
176 | 176 | */ |
177 | 177 | public static function create() |
178 | 178 | { |
@@ -1,17 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | use POData\Providers\Metadata\ResourceStreamInfo; |
4 | -use POData\Providers\Metadata\ResourceAssociationSetEnd; |
|
5 | -use POData\Providers\Metadata\ResourceAssociationSet; |
|
6 | -use POData\Common\NotImplementedException; |
|
7 | 4 | use POData\Providers\Metadata\Type\EdmPrimitiveType; |
8 | -use POData\Providers\Metadata\ResourceSet; |
|
9 | -use POData\Providers\Metadata\ResourcePropertyKind; |
|
10 | -use POData\Providers\Metadata\ResourceProperty; |
|
11 | -use POData\Providers\Metadata\ResourceTypeKind; |
|
12 | -use POData\Providers\Metadata\ResourceType; |
|
13 | 5 | use POData\Common\InvalidOperationException; |
14 | -use POData\Providers\Metadata\IMetadataProvider; |
|
15 | 6 | require_once 'POData\Providers\Metadata\IDataServiceMetadataProvider.php'; |
16 | 7 | use POData\Providers\Metadata\SimpleMetadataProvider; |
17 | 8 | //Begin Resource Classes |
@@ -117,49 +117,49 @@ |
||
117 | 117 | class Employee |
118 | 118 | { |
119 | 119 | //Key Edm.Int32 |
120 | - public $EmployeeID; |
|
121 | - //Edm.String |
|
122 | - public $FirstName; |
|
123 | - //Edm.String |
|
124 | - public $LastName; |
|
125 | - //Edm.String |
|
126 | - public $Title; |
|
127 | - //Edm.String |
|
128 | - public $TitleOfCourtesy; |
|
129 | - //Edm.DateTime |
|
130 | - public $BirthDate; |
|
131 | - //Edm.DateTime |
|
132 | - public $HireDate; |
|
133 | - //Edm.String |
|
134 | - public $Address; |
|
135 | - //Edm.String |
|
136 | - public $City; |
|
137 | - //Edm.String |
|
138 | - public $Region; |
|
139 | - //Edm.String |
|
140 | - public $PostalCode; |
|
141 | - //Edm.String |
|
142 | - public $Country; |
|
143 | - //Edm.String |
|
144 | - public $HomePhone; |
|
145 | - //Edm.String |
|
146 | - public $Extension; |
|
147 | - //Edm.String |
|
148 | - public $Notes; |
|
149 | - //Bag of strings |
|
150 | - public $Emails; |
|
151 | - //Edm.Int32 |
|
152 | - public $ReportsTo; |
|
153 | - //Edm.Binary |
|
154 | - public $Photo; |
|
155 | - //Edm.String |
|
156 | - public $PhotoPath; |
|
157 | - //Navigation Property to associated instance of Employee instance |
|
158 | - //representing manager (ResourceReference) |
|
159 | - //public $Manager; |
|
160 | - //Navigation Property to associated instance of Employee instances |
|
161 | - //representing subordinates (ResourceSetReference) |
|
162 | - //public $Subordinates; |
|
120 | + public $EmployeeID; |
|
121 | + //Edm.String |
|
122 | + public $FirstName; |
|
123 | + //Edm.String |
|
124 | + public $LastName; |
|
125 | + //Edm.String |
|
126 | + public $Title; |
|
127 | + //Edm.String |
|
128 | + public $TitleOfCourtesy; |
|
129 | + //Edm.DateTime |
|
130 | + public $BirthDate; |
|
131 | + //Edm.DateTime |
|
132 | + public $HireDate; |
|
133 | + //Edm.String |
|
134 | + public $Address; |
|
135 | + //Edm.String |
|
136 | + public $City; |
|
137 | + //Edm.String |
|
138 | + public $Region; |
|
139 | + //Edm.String |
|
140 | + public $PostalCode; |
|
141 | + //Edm.String |
|
142 | + public $Country; |
|
143 | + //Edm.String |
|
144 | + public $HomePhone; |
|
145 | + //Edm.String |
|
146 | + public $Extension; |
|
147 | + //Edm.String |
|
148 | + public $Notes; |
|
149 | + //Bag of strings |
|
150 | + public $Emails; |
|
151 | + //Edm.Int32 |
|
152 | + public $ReportsTo; |
|
153 | + //Edm.Binary |
|
154 | + public $Photo; |
|
155 | + //Edm.String |
|
156 | + public $PhotoPath; |
|
157 | + //Navigation Property to associated instance of Employee instance |
|
158 | + //representing manager (ResourceReference) |
|
159 | + //public $Manager; |
|
160 | + //Navigation Property to associated instance of Employee instances |
|
161 | + //representing subordinates (ResourceSetReference) |
|
162 | + //public $Subordinates; |
|
163 | 163 | } |
164 | 164 | //End Resource Classes |
165 | 165 |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param array $record each row of customer |
420 | 420 | * |
421 | - * @return object |
|
421 | + * @return Customer |
|
422 | 422 | */ |
423 | 423 | private function _serializeCustomer($record) |
424 | 424 | { |
@@ -461,7 +461,8 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @param Object &$src source |
463 | 463 | * @param Object &$target target |
464 | - * @param Object $tag tag |
|
464 | + * @param integer $tag tag |
|
465 | + * @param Address $target |
|
465 | 466 | * |
466 | 467 | * @return void |
467 | 468 | */ |
@@ -503,7 +504,7 @@ discard block |
||
503 | 504 | * |
504 | 505 | * @param array $record each row of customer |
505 | 506 | * |
506 | - * @return object |
|
507 | + * @return Order |
|
507 | 508 | */ |
508 | 509 | private function _serializeOrder($record) |
509 | 510 | { |
@@ -547,7 +548,7 @@ discard block |
||
547 | 548 | * |
548 | 549 | * @param array $record each row of employee |
549 | 550 | * |
550 | - * @return object |
|
551 | + * @return Employee |
|
551 | 552 | */ |
552 | 553 | private function _serializeEmployee($record) |
553 | 554 | { |
@@ -595,7 +596,7 @@ discard block |
||
595 | 596 | * |
596 | 597 | * @param array $record each row of order detail |
597 | 598 | * |
598 | - * @return object |
|
599 | + * @return Order_Details |
|
599 | 600 | */ |
600 | 601 | private function _serializeOrderDetail($record) |
601 | 602 | { |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function __construct() |
42 | 42 | { |
43 | - $connectionInfo = array("Database" => DATABASE); |
|
43 | + $connectionInfo = array("Database" => DATABASE); |
|
44 | 44 | if (defined('UID')) { |
45 | - $connectionInfo['UID'] = UID; |
|
46 | - $connectionInfo['PWD'] = PWD; |
|
47 | - } |
|
45 | + $connectionInfo['UID'] = UID; |
|
46 | + $connectionInfo['PWD'] = PWD; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | $this->_connectionHandle = sqlsrv_connect(SERVER, $connectionInfo); |
50 | 50 | if ( $this->_connectionHandle ) { |
51 | 51 | } else { |
52 | 52 | $errorAsString = self::_getSQLSRVError(); |
53 | - throw ODataException::createInternalServerError($errorAsString); |
|
53 | + throw ODataException::createInternalServerError($errorAsString); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->_northWindSQLSRVExpressionProvider = null; |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getExpressionProvider() |
73 | 73 | { |
74 | - if (is_null($this->_northWindSQLSRVExpressionProvider)) { |
|
75 | - $this->_northWindSQLSRVExpressionProvider = new NorthWindDSExpressionProvider(); |
|
76 | - } |
|
74 | + if (is_null($this->_northWindSQLSRVExpressionProvider)) { |
|
75 | + $this->_northWindSQLSRVExpressionProvider = new NorthWindDSExpressionProvider(); |
|
76 | + } |
|
77 | 77 | |
78 | - return $this->_northWindSQLSRVExpressionProvider; |
|
78 | + return $this->_northWindSQLSRVExpressionProvider; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | && $resourceSetName !== 'Order_Details' |
101 | 101 | && $resourceSetName !== 'Employees' |
102 | 102 | ) { |
103 | - throw ODataException::createInternalServerError('(NorthWindQueryProvider) Unknown resource set ' . $resourceSetName . '! Contact service provider'); |
|
103 | + throw ODataException::createInternalServerError('(NorthWindQueryProvider) Unknown resource set ' . $resourceSetName . '! Contact service provider'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if ($resourceSetName === 'Order_Details') { |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
115 | 115 | if ($stmt === false) { |
116 | 116 | $errorAsString = self::_getSQLSRVError(); |
117 | - throw ODataException::createInternalServerError($errorAsString); |
|
117 | + throw ODataException::createInternalServerError($errorAsString); |
|
118 | 118 | } |
119 | 119 | $returnResult = array(); |
120 | 120 | switch ($resourceSetName) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
173 | 173 | if ($stmt === false) { |
174 | 174 | $errorAsString = self::_getSQLSRVError(); |
175 | - throw ODataException::createInternalServerError($errorAsString); |
|
175 | + throw ODataException::createInternalServerError($errorAsString); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | //If resource not found return null to the library |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
238 | 238 | if ($stmt === false) { |
239 | 239 | $errorAsString = self::_getSQLSRVError(); |
240 | - throw ODataException::createInternalServerError($errorAsString); |
|
240 | + throw ODataException::createInternalServerError($errorAsString); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | $result = $this->_serializeOrders($stmt); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
251 | 251 | if ($stmt === false) { |
252 | 252 | $errorAsString = self::_getSQLSRVError(); |
253 | - throw ODataException::createInternalServerError($errorAsString); |
|
253 | + throw ODataException::createInternalServerError($errorAsString); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | $result = $this->_serializeOrderDetails($stmt); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
302 | 302 | if ($stmt === false) { |
303 | 303 | $errorAsString = self::_getSQLSRVError(); |
304 | - throw ODataException::createInternalServerError($errorAsString); |
|
304 | + throw ODataException::createInternalServerError($errorAsString); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | $result = $this->_serializeOrders($stmt); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
318 | 318 | if ($stmt === false) { |
319 | 319 | $errorAsString = self::_getSQLSRVError(); |
320 | - throw ODataException::createInternalServerError($errorAsString); |
|
320 | + throw ODataException::createInternalServerError($errorAsString); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | $result = $this->_serializeOrderDetails($stmt); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
359 | 359 | if ($stmt === false) { |
360 | 360 | $errorAsString = self::_getSQLSRVError(); |
361 | - throw ODataException::createInternalServerError($errorAsString); |
|
361 | + throw ODataException::createInternalServerError($errorAsString); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | if (!sqlsrv_has_rows($stmt)) { |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
380 | 380 | if ($stmt === false) { |
381 | 381 | $errorAsString = self::_getSQLSRVError(); |
382 | - throw ODataException::createInternalServerError($errorAsString); |
|
382 | + throw ODataException::createInternalServerError($errorAsString); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | if (!sqlsrv_has_rows($stmt)) { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | { |
408 | 408 | $customers = array(); |
409 | 409 | while ($record = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { |
410 | - $customers[] = $this->_serializeCustomer($record); |
|
410 | + $customers[] = $this->_serializeCustomer($record); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | return $customers; |
@@ -456,15 +456,15 @@ discard block |
||
456 | 456 | return $customer; |
457 | 457 | } |
458 | 458 | |
459 | - /** |
|
460 | - * copy address |
|
461 | - * |
|
462 | - * @param Object &$src source |
|
463 | - * @param Object &$target target |
|
464 | - * @param Object $tag tag |
|
465 | - * |
|
466 | - * @return void |
|
467 | - */ |
|
459 | + /** |
|
460 | + * copy address |
|
461 | + * |
|
462 | + * @param Object &$src source |
|
463 | + * @param Object &$target target |
|
464 | + * @param Object $tag tag |
|
465 | + * |
|
466 | + * @return void |
|
467 | + */ |
|
468 | 468 | private function _copyAddress(&$src, &$target, $tag) |
469 | 469 | { |
470 | 470 | $target->StreetName = $src->StreetName . $tag; |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | { |
493 | 493 | $orders = array(); |
494 | 494 | while ( $record = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { |
495 | - $orders[] = $this->_serializeOrder($record); |
|
495 | + $orders[] = $this->_serializeOrder($record); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return $orders; |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | { |
537 | 537 | $employees = array(); |
538 | 538 | while ($record = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { |
539 | - $employees[] = $this->_serializeEmployee($record); |
|
539 | + $employees[] = $this->_serializeEmployee($record); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | return $employees; |
@@ -616,10 +616,10 @@ discard block |
||
616 | 616 | */ |
617 | 617 | private static function _getSQLSRVError() |
618 | 618 | { |
619 | - $result = null; |
|
620 | - $errors = sqlsrv_errors(); |
|
621 | - self::_getSQLSRVError1($errors, $result); |
|
622 | - return $result; |
|
619 | + $result = null; |
|
620 | + $errors = sqlsrv_errors(); |
|
621 | + self::_getSQLSRVError1($errors, $result); |
|
622 | + return $result; |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
@@ -630,13 +630,13 @@ discard block |
||
630 | 630 | */ |
631 | 631 | private static function _getSQLSRVError1($errors, &$result) |
632 | 632 | { |
633 | - if (is_array($errors)) { |
|
634 | - foreach ($errors as $error) { |
|
635 | - self::_getSQLSRVError1($error, $result); |
|
636 | - } |
|
637 | - } else { |
|
638 | - $result .= $errors; |
|
639 | - } |
|
633 | + if (is_array($errors)) { |
|
634 | + foreach ($errors as $error) { |
|
635 | + self::_getSQLSRVError1($error, $result); |
|
636 | + } |
|
637 | + } else { |
|
638 | + $result .= $errors; |
|
639 | + } |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | } |
119 | 119 | $returnResult = array(); |
120 | 120 | switch ($resourceSetName) { |
121 | - case 'Customers': |
|
122 | - $returnResult = $this->_serializeCustomers($stmt); |
|
123 | - break; |
|
124 | - case 'Orders': |
|
125 | - $returnResult = $this->_serializeOrders($stmt); |
|
126 | - break; |
|
127 | - case 'Order Details': |
|
128 | - $returnResult = $this->_serializeOrderDetails($stmt); |
|
129 | - break; |
|
130 | - case 'Employees': |
|
131 | - $returnResult = $this->_serializeEmployees($stmt); |
|
132 | - break; |
|
121 | + case 'Customers': |
|
122 | + $returnResult = $this->_serializeCustomers($stmt); |
|
123 | + break; |
|
124 | + case 'Orders': |
|
125 | + $returnResult = $this->_serializeOrders($stmt); |
|
126 | + break; |
|
127 | + case 'Order Details': |
|
128 | + $returnResult = $this->_serializeOrderDetails($stmt); |
|
129 | + break; |
|
130 | + case 'Employees': |
|
131 | + $returnResult = $this->_serializeEmployees($stmt); |
|
132 | + break; |
|
133 | 133 | } |
134 | 134 | sqlsrv_free_stmt($stmt); |
135 | 135 | return $returnResult; |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | $result = null; |
184 | 184 | while ( $record = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { |
185 | 185 | switch ($resourceSetName) { |
186 | - case 'Customers': |
|
187 | - $result = $this->_serializeCustomer($record); |
|
188 | - break; |
|
189 | - case 'Orders': |
|
190 | - $result = $this->_serializeOrder($record); |
|
191 | - break; |
|
192 | - case 'Order Details': |
|
193 | - $result = $this->_serializeOrderDetail($record); |
|
194 | - break; |
|
195 | - case 'Employees': |
|
196 | - $result = $this->_serializeEmployee($record); |
|
197 | - break; |
|
186 | + case 'Customers': |
|
187 | + $result = $this->_serializeCustomer($record); |
|
188 | + break; |
|
189 | + case 'Orders': |
|
190 | + $result = $this->_serializeOrder($record); |
|
191 | + break; |
|
192 | + case 'Order Details': |
|
193 | + $result = $this->_serializeOrderDetail($record); |
|
194 | + break; |
|
195 | + case 'Employees': |
|
196 | + $result = $this->_serializeEmployee($record); |
|
197 | + break; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | sqlsrv_free_stmt($stmt); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | $this->_connectionHandle = sqlsrv_connect(SERVER, $connectionInfo); |
50 | - if ( $this->_connectionHandle ) { |
|
50 | + if ($this->_connectionHandle) { |
|
51 | 51 | } else { |
52 | 52 | $errorAsString = self::_getSQLSRVError(); |
53 | 53 | throw ODataException::createInternalServerError($errorAsString); |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | * @return array(Object) |
93 | 93 | */ |
94 | 94 | public function getResourceSet(ResourceSet $resourceSet, $filterOption = null, |
95 | - $select=null, $orderby=null, $top=null, $skip=null |
|
95 | + $select = null, $orderby = null, $top = null, $skip = null |
|
96 | 96 | ) { |
97 | - $resourceSetName = $resourceSet->getName(); |
|
97 | + $resourceSetName = $resourceSet->getName(); |
|
98 | 98 | if ($resourceSetName !== 'Customers' |
99 | 99 | && $resourceSetName !== 'Orders' |
100 | 100 | && $resourceSetName !== 'Order_Details' |
101 | 101 | && $resourceSetName !== 'Employees' |
102 | 102 | ) { |
103 | - throw ODataException::createInternalServerError('(NorthWindQueryProvider) Unknown resource set ' . $resourceSetName . '! Contact service provider'); |
|
103 | + throw ODataException::createInternalServerError('(NorthWindQueryProvider) Unknown resource set '.$resourceSetName.'! Contact service provider'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if ($resourceSetName === 'Order_Details') { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | $query = "SELECT * FROM [$resourceSetName]"; |
111 | 111 | if ($filterOption != null) { |
112 | - $query .= ' WHERE ' . $filterOption; |
|
112 | + $query .= ' WHERE '.$filterOption; |
|
113 | 113 | } |
114 | 114 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
115 | 115 | if ($stmt === false) { |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getResourceFromResourceSet(ResourceSet $resourceSet, KeyDescriptor $keyDescriptor) |
148 | 148 | { |
149 | - $resourceSetName = $resourceSet->getName(); |
|
149 | + $resourceSetName = $resourceSet->getName(); |
|
150 | 150 | if ($resourceSetName !== 'Customers' |
151 | 151 | && $resourceSetName !== 'Orders' |
152 | 152 | && $resourceSetName !== 'Order_Details' |
153 | 153 | && $resourceSetName !== 'Products' |
154 | 154 | && $resourceSetName !== 'Employees' |
155 | 155 | ) { |
156 | - die('(NorthWindQueryProvider) Unknown resource set ' . $resourceSetName); |
|
156 | + die('(NorthWindQueryProvider) Unknown resource set '.$resourceSetName); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | if ($resourceSetName === 'Order_Details') { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $namedKeyValues = $keyDescriptor->getValidatedNamedValues(); |
164 | 164 | $condition = null; |
165 | 165 | foreach ($namedKeyValues as $key => $value) { |
166 | - $condition .= $key . ' = ' . $value[0] . ' and '; |
|
166 | + $condition .= $key.' = '.$value[0].' and '; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $len = strlen($condition); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | $result = null; |
184 | - while ( $record = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { |
|
184 | + while ($record = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { |
|
185 | 185 | switch ($resourceSetName) { |
186 | 186 | case 'Customers': |
187 | 187 | $result = $this->_serializeCustomer($record); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $navigationPropName = $targetProperty->getName(); |
228 | 228 | $key = null; |
229 | 229 | foreach ($keyDescriptor->getValidatedNamedValues() as $keyName => $valueDescription) { |
230 | - $key = $key . $keyName . '=' . $valueDescription[0] . ' and '; |
|
230 | + $key = $key.$keyName.'='.$valueDescription[0].' and '; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | $key = rtrim($key, ' and '); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $result = $this->_serializeOrders($stmt); |
244 | 244 | } else { |
245 | - die('Customer does not have navigation porperty with name: ' . $navigationPropName); |
|
245 | + die('Customer does not have navigation porperty with name: '.$navigationPropName); |
|
246 | 246 | } |
247 | 247 | } else if ($srcClass === 'Order') { |
248 | 248 | if ($navigationPropName === 'Order_Details') { |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | $result = $this->_serializeOrderDetails($stmt); |
257 | 257 | } else { |
258 | - die('Order does not have navigation porperty with name: ' . $navigationPropName); |
|
258 | + die('Order does not have navigation porperty with name: '.$navigationPropName); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | ResourceSet $targetResourceSet, |
288 | 288 | ResourceProperty $targetProperty, |
289 | 289 | $filterOption = null, |
290 | - $select=null, $orderby=null, $top=null, $skip=null |
|
290 | + $select = null, $orderby = null, $top = null, $skip = null |
|
291 | 291 | ) { |
292 | 292 | $result = array(); |
293 | 293 | $srcClass = get_class($sourceEntityInstance); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | if ($navigationPropName === 'Orders') { |
297 | 297 | $query = "SELECT * FROM Orders WHERE CustomerID = '$sourceEntityInstance->CustomerID'"; |
298 | 298 | if ($filterOption != null) { |
299 | - $query .= ' AND ' . $filterOption; |
|
299 | + $query .= ' AND '.$filterOption; |
|
300 | 300 | } |
301 | 301 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
302 | 302 | if ($stmt === false) { |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | |
307 | 307 | $result = $this->_serializeOrders($stmt); |
308 | 308 | } else { |
309 | - die('Customer does not have navigation porperty with name: ' . $navigationPropName); |
|
309 | + die('Customer does not have navigation porperty with name: '.$navigationPropName); |
|
310 | 310 | } |
311 | 311 | } else if ($srcClass === 'Order') { |
312 | 312 | if ($navigationPropName === 'Order_Details') { |
313 | 313 | $query = "SELECT * FROM [Order Details] WHERE OrderID = $sourceEntityInstance->OrderID"; |
314 | 314 | if ($filterOption != null) { |
315 | - $query .= ' AND ' . $filterOption; |
|
315 | + $query .= ' AND '.$filterOption; |
|
316 | 316 | } |
317 | 317 | $stmt = sqlsrv_query($this->_connectionHandle, $query); |
318 | 318 | if ($stmt === false) { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | $result = $this->_serializeOrderDetails($stmt); |
324 | 324 | } else { |
325 | - die('Order does not have navigation porperty with name: ' . $navigationPropName); |
|
325 | + die('Order does not have navigation porperty with name: '.$navigationPropName); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
@@ -362,13 +362,13 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | if (!sqlsrv_has_rows($stmt)) { |
365 | - $result = null; |
|
365 | + $result = null; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | $result = $this->_serializeCustomer(sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)); |
369 | 369 | } |
370 | 370 | } else { |
371 | - die('Customer does not have navigation porperty with name: ' . $navigationPropName); |
|
371 | + die('Customer does not have navigation porperty with name: '.$navigationPropName); |
|
372 | 372 | } |
373 | 373 | } else if ($srcClass === 'Order_Details') { |
374 | 374 | if ($navigationPropName === 'Order') { |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | } |
384 | 384 | |
385 | 385 | if (!sqlsrv_has_rows($stmt)) { |
386 | - $result = null; |
|
386 | + $result = null; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | $result = $this->_serializeOrder(sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)); |
390 | 390 | } |
391 | 391 | } else { |
392 | - die('Order_Details does not have navigation porperty with name: ' . $navigationPropName); |
|
392 | + die('Order_Details does not have navigation porperty with name: '.$navigationPropName); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -437,14 +437,14 @@ discard block |
||
437 | 437 | $customer->Address->Country = $record['Country']; |
438 | 438 | //Set alternate address |
439 | 439 | $customer->Address->AltAddress = new Address(); |
440 | - $customer->Address->AltAddress->StreetName = 'ALT_' . $customer->Address->StreetName; |
|
441 | - $customer->Address->AltAddress->City = 'ALT_' . $customer->Address->City; |
|
442 | - $customer->Address->AltAddress->Region = 'ALT_' . $customer->Address->Region; |
|
443 | - $customer->Address->AltAddress->PostalCode = 'ALT_' . $customer->Address->PostalCode; |
|
444 | - $customer->Address->AltAddress->Country = 'ALT_' . $customer->Address->Country; |
|
440 | + $customer->Address->AltAddress->StreetName = 'ALT_'.$customer->Address->StreetName; |
|
441 | + $customer->Address->AltAddress->City = 'ALT_'.$customer->Address->City; |
|
442 | + $customer->Address->AltAddress->Region = 'ALT_'.$customer->Address->Region; |
|
443 | + $customer->Address->AltAddress->PostalCode = 'ALT_'.$customer->Address->PostalCode; |
|
444 | + $customer->Address->AltAddress->Country = 'ALT_'.$customer->Address->Country; |
|
445 | 445 | $customer->EmailAddresses = array(); |
446 | 446 | for ($i = 1; $i < 4; $i++) { |
447 | - $customer->EmailAddresses[] = $customer->CustomerID . $i . '@live.com'; |
|
447 | + $customer->EmailAddresses[] = $customer->CustomerID.$i.'@live.com'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | $customer->OtherAddresses = array(); |
@@ -467,18 +467,18 @@ discard block |
||
467 | 467 | */ |
468 | 468 | private function _copyAddress(&$src, &$target, $tag) |
469 | 469 | { |
470 | - $target->StreetName = $src->StreetName . $tag; |
|
471 | - $target->City = $src->City . $tag; |
|
472 | - $target->Region = $src->Region . $tag; |
|
473 | - $target->PostalCode = $src->PostalCode . $tag; |
|
474 | - $target->Country = $src->Country . $tag; |
|
470 | + $target->StreetName = $src->StreetName.$tag; |
|
471 | + $target->City = $src->City.$tag; |
|
472 | + $target->Region = $src->Region.$tag; |
|
473 | + $target->PostalCode = $src->PostalCode.$tag; |
|
474 | + $target->Country = $src->Country.$tag; |
|
475 | 475 | |
476 | 476 | $target->AltAddress = new Address(); |
477 | - $target->AltAddress->StreetName = $target->AltAddress->StreetName . $tag; |
|
478 | - $target->AltAddress->City = $target->AltAddress->City . $tag; |
|
479 | - $target->AltAddress->Region = $target->AltAddress->Region . $tag; |
|
480 | - $target->AltAddress->PostalCode = $target->AltAddress->PostalCode . $tag; |
|
481 | - $target->AltAddress->Country = $target->AltAddress->Country . $tag; |
|
477 | + $target->AltAddress->StreetName = $target->AltAddress->StreetName.$tag; |
|
478 | + $target->AltAddress->City = $target->AltAddress->City.$tag; |
|
479 | + $target->AltAddress->Region = $target->AltAddress->Region.$tag; |
|
480 | + $target->AltAddress->PostalCode = $target->AltAddress->PostalCode.$tag; |
|
481 | + $target->AltAddress->Country = $target->AltAddress->Country.$tag; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | private function _serializeOrders($result) |
492 | 492 | { |
493 | 493 | $orders = array(); |
494 | - while ( $record = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { |
|
494 | + while ($record = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { |
|
495 | 495 | $orders[] = $this->_serializeOrder($record); |
496 | 496 | } |
497 | 497 | |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | $order->OrderID = $record['OrderID']; |
512 | 512 | $order->CustomerID = $record['CustomerID']; |
513 | 513 | $order->EmployeeID = $record['EmployeeID']; |
514 | - $order->OrderDate = !is_null($record['OrderDate']) ? $record['OrderDate']->format('Y-m-d\TH:i:s'): null; |
|
515 | - $order->RequiredDate = !is_null($record['RequiredDate']) ? $record['RequiredDate']->format('Y-m-d\TH:i:s'): null; |
|
516 | - $order->ShippedDate = !is_null($record['ShippedDate']) ? $record['ShippedDate']->format('Y-m-d\TH:i:s'): null; |
|
514 | + $order->OrderDate = !is_null($record['OrderDate']) ? $record['OrderDate']->format('Y-m-d\TH:i:s') : null; |
|
515 | + $order->RequiredDate = !is_null($record['RequiredDate']) ? $record['RequiredDate']->format('Y-m-d\TH:i:s') : null; |
|
516 | + $order->ShippedDate = !is_null($record['ShippedDate']) ? $record['ShippedDate']->format('Y-m-d\TH:i:s') : null; |
|
517 | 517 | $order->ShipVia = $record['ShipVia']; |
518 | 518 | $order->Freight = $record['Freight']; |
519 | 519 | $order->ShipName = $record['ShipName']; |
@@ -557,8 +557,8 @@ discard block |
||
557 | 557 | $employee->LastName = $record['LastName']; |
558 | 558 | $employee->Title = $record['Title']; |
559 | 559 | $employee->TitleOfCourtesy = $record['TitleOfCourtesy']; |
560 | - $employee->BirthDate = !is_null($record['BirthDate']) ? $record['BirthDate']->format('Y-m-d\TH:i:s'): null; |
|
561 | - $employee->HireDate = !is_null($record['HireDate']) ? $record['HireDate']->format('Y-m-d\TH:i:s'): null; |
|
560 | + $employee->BirthDate = !is_null($record['BirthDate']) ? $record['BirthDate']->format('Y-m-d\TH:i:s') : null; |
|
561 | + $employee->HireDate = !is_null($record['HireDate']) ? $record['HireDate']->format('Y-m-d\TH:i:s') : null; |
|
562 | 562 | $employee->Address = $record['Address']; |
563 | 563 | $employee->City = $record['City']; |
564 | 564 | $employee->Region = $record['Region']; |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | $employee->Notes = $record['Notes']; |
570 | 570 | $employee->ReportsTo = $record['ReportsTo']; |
571 | 571 | //$employee->Photo = $record['Photo']; |
572 | - $employee->Emails = array ($employee->FirstName . '@hotmail.com', $employee->FirstName . '@live.com'); |
|
572 | + $employee->Emails = array($employee->FirstName.'@hotmail.com', $employee->FirstName.'@live.com'); |
|
573 | 573 | return $employee; |
574 | 574 | } |
575 | 575 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param WebOperationContext $operationContext A reference to the context |
49 | 49 | * for the current operation. |
50 | 50 | * |
51 | - * @return mixed A valid default stream which is associated with the entity, |
|
51 | + * @return string A valid default stream which is associated with the entity, |
|
52 | 52 | * Null should never be returned from this method. |
53 | 53 | * |
54 | 54 | * @throws ODataException if a valid stream cannot be returned. |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * conditional request. |
213 | 213 | * @param WebOperationContext $operationContext A reference to the context for the current operation. |
214 | 214 | * |
215 | - * @return mixed A valid stream the data service use to query/read a named stream which is |
|
215 | + * @return string A valid stream the data service use to query/read a named stream which is |
|
216 | 216 | * associated with the $entity. Null may be returned from this method if the requested named |
217 | 217 | * stream has not been created since the creation of $entity. The data service will respond |
218 | 218 | * with 204 if this method returns null. |
@@ -230,7 +230,7 @@ |
||
230 | 230 | 400 |
231 | 231 | ); |
232 | 232 | } |
233 | - **/ |
|
233 | + **/ |
|
234 | 234 | |
235 | 235 | if (!($entity instanceof Employee)) { |
236 | 236 | throw new ODataException('Internal Server Error.', 500); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | $filePath = self::IMAGE_PATH_ROOT |
79 | - . 'Employee_' . $entity->EmployeeID |
|
79 | + . 'Employee_'.$entity->EmployeeID |
|
80 | 80 | . '.jpg'; |
81 | 81 | if (file_exists($filePath)) { |
82 | 82 | $handle = fopen($filePath, 'r'); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | $lastModifiedTime = null; |
155 | - $filePath = self::IMAGE_PATH_ROOT . 'Employee_' . $entity->EmployeeID . '.jpg'; |
|
155 | + $filePath = self::IMAGE_PATH_ROOT.'Employee_'.$entity->EmployeeID.'.jpg'; |
|
156 | 156 | if (file_exists($filePath)) { |
157 | 157 | $lastModifiedTime = date("\"m-d-Y H:i:s\"", filemtime($filePath)); |
158 | 158 | } else { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | throw new ODataException('Internal Server Error.', 500); |
237 | 237 | } |
238 | 238 | |
239 | - $filePath = self::IMAGE_PATH_ROOT . 'Employee_' |
|
239 | + $filePath = self::IMAGE_PATH_ROOT.'Employee_' |
|
240 | 240 | . $entity->EmployeeID |
241 | 241 | . '_' |
242 | 242 | . $resourceStreamInfo->getName() |
@@ -8,11 +8,6 @@ |
||
8 | 8 | use POData\Configuration\ProtocolVersion; |
9 | 9 | use POData\Configuration\ServiceConfiguration; |
10 | 10 | use POData\BaseService; |
11 | -use POData\OperationContext\ServiceHost; |
|
12 | -use POData\Common\ODataException; |
|
13 | -use POData\Common\ODataConstants; |
|
14 | -use POData\Common\Messages; |
|
15 | -use POData\UriProcessor\UriProcessor; |
|
16 | 11 | require_once 'WordPressMetadata.php'; |
17 | 12 | require_once 'WordPressQueryProvider.php'; |
18 | 13 | require_once 'WordPressDSExpressionProvider.php'; |
@@ -53,13 +53,13 @@ |
||
53 | 53 | */ |
54 | 54 | public function getService($serviceType) |
55 | 55 | { |
56 | - if(($serviceType === 'IMetadataProvider') || |
|
56 | + if(($serviceType === 'IMetadataProvider') || |
|
57 | 57 | ($serviceType === 'IQueryProvider') || |
58 | 58 | ($serviceType === 'IStreamProvider')) { |
59 | 59 | if (is_null($this->_wordPressExpressionProvider)) { |
60 | 60 | $this->_wordPressExpressionProvider = new WordPressDSExpressionProvider(); |
61 | 61 | } |
62 | - } |
|
62 | + } |
|
63 | 63 | if ($serviceType === 'IMetadataProvider') { |
64 | 64 | if (is_null($this->_wordPressMetadata)) { |
65 | 65 | $this->_wordPressMetadata = CreateWordPressMetadata::create(); |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public function getService($serviceType) |
55 | 55 | { |
56 | - if(($serviceType === 'IMetadataProvider') || |
|
56 | + if (($serviceType === 'IMetadataProvider') || |
|
57 | 57 | ($serviceType === 'IQueryProvider') || |
58 | 58 | ($serviceType === 'IStreamProvider')) { |
59 | 59 | if (is_null($this->_wordPressExpressionProvider)) { |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | use POData\UriProcessor\QueryProcessor\ExpressionParser\Expressions\ExpressionType; |
4 | 4 | use POData\Providers\Metadata\Type\IType; |
5 | -use POData\Common\NotImplementedException; |
|
6 | 5 | use POData\Common\ODataConstants; |
7 | 6 | use POData\Providers\Expression\IExpressionProvider; |
8 | 7 | use POData\Providers\Metadata\ResourceType; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function __construct() |
51 | 51 | { |
52 | - $this->_entityMapping = CreateWordPressMetadata::getEntityMapping(); |
|
52 | + $this->_entityMapping = CreateWordPressMetadata::getEntityMapping(); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function setResourceType(ResourceType $resourceType) |
72 | 72 | { |
73 | - $this->_resourceType = $resourceType; |
|
73 | + $this->_resourceType = $resourceType; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | $entityTypeName = $this->_resourceType->getName(); |
224 | 224 | $propertyName = $parent->getResourceProperty()->getName(); |
225 | 225 | if (is_array($this->_entityMapping)) { |
226 | - if (array_key_exists($entityTypeName, $this->_entityMapping)) { |
|
226 | + if (array_key_exists($entityTypeName, $this->_entityMapping)) { |
|
227 | 227 | if (array_key_exists($propertyName, $this->_entityMapping[$entityTypeName])) { |
228 | - return $this->_entityMapping[$entityTypeName][$propertyName]; |
|
228 | + return $this->_entityMapping[$entityTypeName][$propertyName]; |
|
229 | + } |
|
229 | 230 | } |
230 | - } |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | return $propertyName; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | return "LENGTH($params[0])"; |
284 | 284 | break; |
285 | 285 | case ODataConstants::GUIDFUN_EQUAL: |
286 | - return "STRCMP($params[0], $params[1])"; |
|
286 | + return "STRCMP($params[0], $params[1])"; |
|
287 | 287 | break; |
288 | 288 | case ODataConstants::DATETIME_COMPARE: |
289 | 289 | return "DATETIMECMP($params[0]; $params[1])"; |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | */ |
339 | 339 | private function _prepareBinaryExpression($operator, $left, $right) |
340 | 340 | { |
341 | - // Special handling for DATETIMECMP |
|
342 | - if (!substr_compare($left, "DATETIMECMP", 0, 11)) { |
|
341 | + // Special handling for DATETIMECMP |
|
342 | + if (!substr_compare($left, "DATETIMECMP", 0, 11)) { |
|
343 | 343 | $str = explode(';', $left, 2); |
344 | 344 | $str[0] = str_replace('DATETIMECMP', '', $str[0]); |
345 | 345 | return self::OPEN_BRAKET |
346 | - . $str[0] . ' ' . $operator |
|
347 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
348 | - } |
|
346 | + . $str[0] . ' ' . $operator |
|
347 | + . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
348 | + } |
|
349 | 349 | |
350 | 350 | return |
351 | 351 | self::OPEN_BRAKET |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | public function onLogicalExpression($expressionType, $left, $right) |
86 | 86 | { |
87 | 87 | switch($expressionType) { |
88 | - case ExpressionType::AND_LOGICAL: |
|
89 | - return $this->_prepareBinaryExpression(self::LOGICAL_AND, $left, $right); |
|
90 | - break; |
|
91 | - case ExpressionType::OR_LOGICAL: |
|
92 | - return $this->_prepareBinaryExpression(self::LOGICAL_OR, $left, $right); |
|
93 | - break; |
|
94 | - default: |
|
95 | - throw new \InvalidArgumentException('onLogicalExpression'); |
|
88 | + case ExpressionType::AND_LOGICAL: |
|
89 | + return $this->_prepareBinaryExpression(self::LOGICAL_AND, $left, $right); |
|
90 | + break; |
|
91 | + case ExpressionType::OR_LOGICAL: |
|
92 | + return $this->_prepareBinaryExpression(self::LOGICAL_OR, $left, $right); |
|
93 | + break; |
|
94 | + default: |
|
95 | + throw new \InvalidArgumentException('onLogicalExpression'); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | public function onArithmeticExpression($expressionType, $left, $right) |
109 | 109 | { |
110 | 110 | switch($expressionType) { |
111 | - case ExpressionType::MULTIPLY: |
|
112 | - return $this->_prepareBinaryExpression(self::MULTIPLY, $left, $right); |
|
113 | - break; |
|
114 | - case ExpressionType::DIVIDE: |
|
115 | - return $this->_prepareBinaryExpression(self::DIVIDE, $left, $right); |
|
116 | - break; |
|
117 | - case ExpressionType::MODULO: |
|
118 | - return $this->_prepareBinaryExpression(self::MODULO, $left, $right); |
|
119 | - break; |
|
120 | - case ExpressionType::ADD: |
|
121 | - return $this->_prepareBinaryExpression(self::ADD, $left, $right); |
|
122 | - break; |
|
123 | - case ExpressionType::SUBTRACT: |
|
124 | - return $this->_prepareBinaryExpression(self::SUBTRACT, $left, $right); |
|
125 | - break; |
|
126 | - default: |
|
127 | - throw new \InvalidArgumentException('onArithmeticExpression'); |
|
111 | + case ExpressionType::MULTIPLY: |
|
112 | + return $this->_prepareBinaryExpression(self::MULTIPLY, $left, $right); |
|
113 | + break; |
|
114 | + case ExpressionType::DIVIDE: |
|
115 | + return $this->_prepareBinaryExpression(self::DIVIDE, $left, $right); |
|
116 | + break; |
|
117 | + case ExpressionType::MODULO: |
|
118 | + return $this->_prepareBinaryExpression(self::MODULO, $left, $right); |
|
119 | + break; |
|
120 | + case ExpressionType::ADD: |
|
121 | + return $this->_prepareBinaryExpression(self::ADD, $left, $right); |
|
122 | + break; |
|
123 | + case ExpressionType::SUBTRACT: |
|
124 | + return $this->_prepareBinaryExpression(self::SUBTRACT, $left, $right); |
|
125 | + break; |
|
126 | + default: |
|
127 | + throw new \InvalidArgumentException('onArithmeticExpression'); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -140,30 +140,30 @@ discard block |
||
140 | 140 | public function onRelationalExpression($expressionType, $left, $right) |
141 | 141 | { |
142 | 142 | switch($expressionType) { |
143 | - case ExpressionType::GREATERTHAN: |
|
144 | - return $this->_prepareBinaryExpression(self::GREATERTHAN, $left, $right); |
|
145 | - break; |
|
146 | - case ExpressionType::GREATERTHAN_OR_EQUAL: |
|
147 | - return $this->_prepareBinaryExpression( |
|
148 | - self::GREATERTHAN_OR_EQUAL, $left, $right |
|
149 | - ); |
|
150 | - break; |
|
151 | - case ExpressionType::LESSTHAN: |
|
152 | - return $this->_prepareBinaryExpression(self::LESSTHAN, $left, $right); |
|
153 | - break; |
|
154 | - case ExpressionType::LESSTHAN_OR_EQUAL: |
|
155 | - return $this->_prepareBinaryExpression( |
|
156 | - self::LESSTHAN_OR_EQUAL, $left, $right |
|
157 | - ); |
|
158 | - break; |
|
159 | - case ExpressionType::EQUAL: |
|
160 | - return $this->_prepareBinaryExpression(self::EQUAL, $left, $right); |
|
161 | - break; |
|
162 | - case ExpressionType::NOTEQUAL: |
|
163 | - return $this->_prepareBinaryExpression(self::NOTEQUAL, $left, $right); |
|
164 | - break; |
|
165 | - default: |
|
166 | - throw new \InvalidArgumentException('onArithmeticExpression'); |
|
143 | + case ExpressionType::GREATERTHAN: |
|
144 | + return $this->_prepareBinaryExpression(self::GREATERTHAN, $left, $right); |
|
145 | + break; |
|
146 | + case ExpressionType::GREATERTHAN_OR_EQUAL: |
|
147 | + return $this->_prepareBinaryExpression( |
|
148 | + self::GREATERTHAN_OR_EQUAL, $left, $right |
|
149 | + ); |
|
150 | + break; |
|
151 | + case ExpressionType::LESSTHAN: |
|
152 | + return $this->_prepareBinaryExpression(self::LESSTHAN, $left, $right); |
|
153 | + break; |
|
154 | + case ExpressionType::LESSTHAN_OR_EQUAL: |
|
155 | + return $this->_prepareBinaryExpression( |
|
156 | + self::LESSTHAN_OR_EQUAL, $left, $right |
|
157 | + ); |
|
158 | + break; |
|
159 | + case ExpressionType::EQUAL: |
|
160 | + return $this->_prepareBinaryExpression(self::EQUAL, $left, $right); |
|
161 | + break; |
|
162 | + case ExpressionType::NOTEQUAL: |
|
163 | + return $this->_prepareBinaryExpression(self::NOTEQUAL, $left, $right); |
|
164 | + break; |
|
165 | + default: |
|
166 | + throw new \InvalidArgumentException('onArithmeticExpression'); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | public function onUnaryExpression($expressionType, $child) |
179 | 179 | { |
180 | 180 | switch($expressionType) { |
181 | - case ExpressionType::NEGATE: |
|
182 | - return $this->_prepareUnaryExpression(self::NEGATE, $child); |
|
183 | - break; |
|
184 | - case ExpressionType::NOT_LOGICAL: |
|
185 | - return $this->_prepareUnaryExpression(self::LOGICAL_NOT, $child); |
|
186 | - break; |
|
187 | - default: |
|
188 | - throw new \InvalidArgumentException('onUnaryExpression'); |
|
181 | + case ExpressionType::NEGATE: |
|
182 | + return $this->_prepareUnaryExpression(self::NEGATE, $child); |
|
183 | + break; |
|
184 | + case ExpressionType::NOT_LOGICAL: |
|
185 | + return $this->_prepareUnaryExpression(self::LOGICAL_NOT, $child); |
|
186 | + break; |
|
187 | + default: |
|
188 | + throw new \InvalidArgumentException('onUnaryExpression'); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
@@ -244,86 +244,86 @@ discard block |
||
244 | 244 | public function onFunctionCallExpression($functionDescription, $params) |
245 | 245 | { |
246 | 246 | switch($functionDescription->functionName) { |
247 | - case ODataConstants::STRFUN_COMPARE: |
|
248 | - return "STRCMP($params[0], $params[1])"; |
|
249 | - break; |
|
250 | - case ODataConstants::STRFUN_ENDSWITH: |
|
251 | - return "(STRCMP($params[1],RIGHT($params[0],LENGTH($params[1]))) = 0)"; |
|
252 | - break; |
|
253 | - case ODataConstants::STRFUN_INDEXOF: |
|
254 | - return "INSTR($params[0], $params[1]) - 1"; |
|
255 | - break; |
|
256 | - case ODataConstants::STRFUN_REPLACE: |
|
257 | - return "REPLACE($params[0],$params[1],$params[2])"; |
|
258 | - break; |
|
259 | - case ODataConstants::STRFUN_STARTSWITH: |
|
260 | - return "(STRCMP($params[1],LEFT($params[0],LENGTH($params[1]))) = 0)"; |
|
261 | - break; |
|
262 | - case ODataConstants::STRFUN_TOLOWER: |
|
263 | - return "LOWER($params[0])"; |
|
264 | - break; |
|
265 | - case ODataConstants::STRFUN_TOUPPER: |
|
266 | - return "UPPER($params[0])"; |
|
267 | - break; |
|
268 | - case ODataConstants::STRFUN_TRIM: |
|
269 | - return "TRIM($params[0])"; |
|
270 | - break; |
|
271 | - case ODataConstants::STRFUN_SUBSTRING: |
|
272 | - return count($params) == 3 ? |
|
273 | - "SUBSTRING($params[0], $params[1] + 1, $params[2])" : |
|
274 | - "SUBSTRING($params[0], $params[1] + 1)"; |
|
275 | - break; |
|
276 | - case ODataConstants::STRFUN_SUBSTRINGOF: |
|
277 | - return "(LOCATE($params[0], $params[1]) > 0)"; |
|
278 | - break; |
|
279 | - case ODataConstants::STRFUN_CONCAT: |
|
280 | - return "CONCAT($params[0],$params[1])"; |
|
281 | - break; |
|
282 | - case ODataConstants::STRFUN_LENGTH: |
|
283 | - return "LENGTH($params[0])"; |
|
284 | - break; |
|
285 | - case ODataConstants::GUIDFUN_EQUAL: |
|
286 | - return "STRCMP($params[0], $params[1])"; |
|
287 | - break; |
|
288 | - case ODataConstants::DATETIME_COMPARE: |
|
289 | - return "DATETIMECMP($params[0]; $params[1])"; |
|
290 | - break; |
|
291 | - case ODataConstants::DATETIME_YEAR: |
|
292 | - return "EXTRACT(YEAR from ".$params[0].")"; |
|
293 | - break; |
|
294 | - case ODataConstants::DATETIME_MONTH: |
|
295 | - return "EXTRACT(MONTH from ".$params[0].")"; |
|
296 | - break; |
|
297 | - case ODataConstants::DATETIME_DAY: |
|
298 | - return "EXTRACT(DAY from ".$params[0].")"; |
|
299 | - break; |
|
300 | - case ODataConstants::DATETIME_HOUR: |
|
301 | - return "EXTRACT(HOUR from ".$params[0].")"; |
|
302 | - break; |
|
303 | - case ODataConstants::DATETIME_MINUTE: |
|
304 | - return "EXTRACT(MINUTE from ".$params[0].")"; |
|
305 | - break; |
|
306 | - case ODataConstants::DATETIME_SECOND: |
|
307 | - return "EXTRACT(SECOND from ".$params[0].")"; |
|
308 | - break; |
|
309 | - case ODataConstants::MATHFUN_ROUND: |
|
310 | - return "ROUND($params[0])"; |
|
311 | - break; |
|
312 | - case ODataConstants::MATHFUN_CEILING: |
|
313 | - return "CEIL($params[0])"; |
|
314 | - break; |
|
315 | - case ODataConstants::MATHFUN_FLOOR: |
|
316 | - return "FLOOR($params[0])"; |
|
317 | - break; |
|
318 | - case ODataConstants::BINFUL_EQUAL: |
|
319 | - return "($params[0] = $params[1])"; |
|
320 | - break; |
|
321 | - case 'is_null': |
|
322 | - return "is_null($params[0])"; |
|
323 | - break; |
|
247 | + case ODataConstants::STRFUN_COMPARE: |
|
248 | + return "STRCMP($params[0], $params[1])"; |
|
249 | + break; |
|
250 | + case ODataConstants::STRFUN_ENDSWITH: |
|
251 | + return "(STRCMP($params[1],RIGHT($params[0],LENGTH($params[1]))) = 0)"; |
|
252 | + break; |
|
253 | + case ODataConstants::STRFUN_INDEXOF: |
|
254 | + return "INSTR($params[0], $params[1]) - 1"; |
|
255 | + break; |
|
256 | + case ODataConstants::STRFUN_REPLACE: |
|
257 | + return "REPLACE($params[0],$params[1],$params[2])"; |
|
258 | + break; |
|
259 | + case ODataConstants::STRFUN_STARTSWITH: |
|
260 | + return "(STRCMP($params[1],LEFT($params[0],LENGTH($params[1]))) = 0)"; |
|
261 | + break; |
|
262 | + case ODataConstants::STRFUN_TOLOWER: |
|
263 | + return "LOWER($params[0])"; |
|
264 | + break; |
|
265 | + case ODataConstants::STRFUN_TOUPPER: |
|
266 | + return "UPPER($params[0])"; |
|
267 | + break; |
|
268 | + case ODataConstants::STRFUN_TRIM: |
|
269 | + return "TRIM($params[0])"; |
|
270 | + break; |
|
271 | + case ODataConstants::STRFUN_SUBSTRING: |
|
272 | + return count($params) == 3 ? |
|
273 | + "SUBSTRING($params[0], $params[1] + 1, $params[2])" : |
|
274 | + "SUBSTRING($params[0], $params[1] + 1)"; |
|
275 | + break; |
|
276 | + case ODataConstants::STRFUN_SUBSTRINGOF: |
|
277 | + return "(LOCATE($params[0], $params[1]) > 0)"; |
|
278 | + break; |
|
279 | + case ODataConstants::STRFUN_CONCAT: |
|
280 | + return "CONCAT($params[0],$params[1])"; |
|
281 | + break; |
|
282 | + case ODataConstants::STRFUN_LENGTH: |
|
283 | + return "LENGTH($params[0])"; |
|
284 | + break; |
|
285 | + case ODataConstants::GUIDFUN_EQUAL: |
|
286 | + return "STRCMP($params[0], $params[1])"; |
|
287 | + break; |
|
288 | + case ODataConstants::DATETIME_COMPARE: |
|
289 | + return "DATETIMECMP($params[0]; $params[1])"; |
|
290 | + break; |
|
291 | + case ODataConstants::DATETIME_YEAR: |
|
292 | + return "EXTRACT(YEAR from ".$params[0].")"; |
|
293 | + break; |
|
294 | + case ODataConstants::DATETIME_MONTH: |
|
295 | + return "EXTRACT(MONTH from ".$params[0].")"; |
|
296 | + break; |
|
297 | + case ODataConstants::DATETIME_DAY: |
|
298 | + return "EXTRACT(DAY from ".$params[0].")"; |
|
299 | + break; |
|
300 | + case ODataConstants::DATETIME_HOUR: |
|
301 | + return "EXTRACT(HOUR from ".$params[0].")"; |
|
302 | + break; |
|
303 | + case ODataConstants::DATETIME_MINUTE: |
|
304 | + return "EXTRACT(MINUTE from ".$params[0].")"; |
|
305 | + break; |
|
306 | + case ODataConstants::DATETIME_SECOND: |
|
307 | + return "EXTRACT(SECOND from ".$params[0].")"; |
|
308 | + break; |
|
309 | + case ODataConstants::MATHFUN_ROUND: |
|
310 | + return "ROUND($params[0])"; |
|
311 | + break; |
|
312 | + case ODataConstants::MATHFUN_CEILING: |
|
313 | + return "CEIL($params[0])"; |
|
314 | + break; |
|
315 | + case ODataConstants::MATHFUN_FLOOR: |
|
316 | + return "FLOOR($params[0])"; |
|
317 | + break; |
|
318 | + case ODataConstants::BINFUL_EQUAL: |
|
319 | + return "($params[0] = $params[1])"; |
|
320 | + break; |
|
321 | + case 'is_null': |
|
322 | + return "is_null($params[0])"; |
|
323 | + break; |
|
324 | 324 | |
325 | - default: |
|
326 | - throw new \InvalidArgumentException('onFunctionCallExpression'); |
|
325 | + default: |
|
326 | + throw new \InvalidArgumentException('onFunctionCallExpression'); |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function onLogicalExpression($expressionType, $left, $right) |
86 | 86 | { |
87 | - switch($expressionType) { |
|
87 | + switch ($expressionType) { |
|
88 | 88 | case ExpressionType::AND_LOGICAL: |
89 | 89 | return $this->_prepareBinaryExpression(self::LOGICAL_AND, $left, $right); |
90 | 90 | break; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function onArithmeticExpression($expressionType, $left, $right) |
109 | 109 | { |
110 | - switch($expressionType) { |
|
110 | + switch ($expressionType) { |
|
111 | 111 | case ExpressionType::MULTIPLY: |
112 | 112 | return $this->_prepareBinaryExpression(self::MULTIPLY, $left, $right); |
113 | 113 | break; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function onRelationalExpression($expressionType, $left, $right) |
141 | 141 | { |
142 | - switch($expressionType) { |
|
142 | + switch ($expressionType) { |
|
143 | 143 | case ExpressionType::GREATERTHAN: |
144 | 144 | return $this->_prepareBinaryExpression(self::GREATERTHAN, $left, $right); |
145 | 145 | break; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function onUnaryExpression($expressionType, $child) |
179 | 179 | { |
180 | - switch($expressionType) { |
|
180 | + switch ($expressionType) { |
|
181 | 181 | case ExpressionType::NEGATE: |
182 | 182 | return $this->_prepareUnaryExpression(self::NEGATE, $child); |
183 | 183 | break; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function onFunctionCallExpression($functionDescription, $params) |
245 | 245 | { |
246 | - switch($functionDescription->functionName) { |
|
246 | + switch ($functionDescription->functionName) { |
|
247 | 247 | case ODataConstants::STRFUN_COMPARE: |
248 | 248 | return "STRCMP($params[0], $params[1])"; |
249 | 249 | break; |
@@ -270,8 +270,7 @@ discard block |
||
270 | 270 | break; |
271 | 271 | case ODataConstants::STRFUN_SUBSTRING: |
272 | 272 | return count($params) == 3 ? |
273 | - "SUBSTRING($params[0], $params[1] + 1, $params[2])" : |
|
274 | - "SUBSTRING($params[0], $params[1] + 1)"; |
|
273 | + "SUBSTRING($params[0], $params[1] + 1, $params[2])" : "SUBSTRING($params[0], $params[1] + 1)"; |
|
275 | 274 | break; |
276 | 275 | case ODataConstants::STRFUN_SUBSTRINGOF: |
277 | 276 | return "(LOCATE($params[0], $params[1]) > 0)"; |
@@ -343,14 +342,14 @@ discard block |
||
343 | 342 | $str = explode(';', $left, 2); |
344 | 343 | $str[0] = str_replace('DATETIMECMP', '', $str[0]); |
345 | 344 | return self::OPEN_BRAKET |
346 | - . $str[0] . ' ' . $operator |
|
347 | - . ' ' . $str[1] . self::CLOSE_BRACKET; |
|
345 | + . $str[0].' '.$operator |
|
346 | + . ' '.$str[1].self::CLOSE_BRACKET; |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | return |
351 | 350 | self::OPEN_BRAKET |
352 | - . $left . ' ' . $operator |
|
353 | - . ' ' . $right . self::CLOSE_BRACKET; |
|
351 | + . $left.' '.$operator |
|
352 | + . ' '.$right.self::CLOSE_BRACKET; |
|
354 | 353 | } |
355 | 354 | |
356 | 355 | /** |
@@ -363,6 +362,6 @@ discard block |
||
363 | 362 | */ |
364 | 363 | private function _prepareUnaryExpression($operator, $child) |
365 | 364 | { |
366 | - return $operator . self::OPEN_BRAKET . $child . self::CLOSE_BRACKET; |
|
365 | + return $operator.self::OPEN_BRAKET.$child.self::CLOSE_BRACKET; |
|
367 | 366 | } |
368 | 367 | } |
@@ -1,20 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -use POData\Providers\Metadata\ResourceStreamInfo; |
|
4 | -use POData\Providers\Metadata\ResourceAssociationSetEnd; |
|
5 | -use POData\Providers\Metadata\ResourceAssociationSet; |
|
6 | -use POData\Common\NotImplementedException; |
|
7 | 3 | use POData\Providers\Metadata\Type\EdmPrimitiveType; |
8 | -use POData\Providers\Metadata\ResourceSet; |
|
9 | -use POData\Providers\Metadata\ResourcePropertyKind; |
|
10 | -use POData\Providers\Metadata\ResourceProperty; |
|
11 | -use POData\Providers\Metadata\ResourceTypeKind; |
|
12 | -use POData\Providers\Metadata\ResourceType; |
|
13 | 4 | use POData\Common\InvalidOperationException; |
14 | -use POData\Providers\Metadata\IMetadataProvider; |
|
15 | 5 | require_once 'POData\Providers\Metadata\IDataServiceMetadataProvider.php'; |
16 | 6 | use POData\Providers\Metadata\SimpleMetadataProvider; |
17 | -use POData\Providers\Metadata\MetadataMapping; |
|
18 | 7 | |
19 | 8 | //Begin Resource Classes |
20 | 9 |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | class CreateWordPressMetadata |
179 | 179 | { |
180 | 180 | |
181 | - /** |
|
182 | - * Array holding the mapping between the entity properties and coulmns. |
|
183 | - * |
|
184 | - * @var array |
|
185 | - */ |
|
181 | + /** |
|
182 | + * Array holding the mapping between the entity properties and coulmns. |
|
183 | + * |
|
184 | + * @var array |
|
185 | + */ |
|
186 | 186 | private static $_entityMapping = array(); |
187 | 187 | |
188 | 188 | /** |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @return array(string, array(string, string)) |
296 | 296 | */ |
297 | 297 | public static function getEntityMapping() { |
298 | - if (!is_null(self::$_entityMapping)) |
|
299 | - { |
|
298 | + if (!is_null(self::$_entityMapping)) |
|
299 | + { |
|
300 | 300 | self::$_entityMapping = array ( |
301 | 301 | 'Post' => array ( |
302 | 302 | '$MappedTable$' => 'wp_posts', |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | 'Type' => 'post_type', |
323 | 323 | 'MimeType' => 'post_mime_type', |
324 | 324 | 'CommentCount' => 'comment_count' |
325 | - ), |
|
325 | + ), |
|
326 | 326 | |
327 | 327 | 'Tag' => array ( |
328 | 328 | '$MappedTable$' => 'wp_terms', |
@@ -369,9 +369,9 @@ discard block |
||
369 | 369 | 'Status' => 'user_status', |
370 | 370 | 'DisplayName' => 'display_name' |
371 | 371 | ) |
372 | - ); |
|
373 | - } |
|
372 | + ); |
|
373 | + } |
|
374 | 374 | |
375 | - return self::$_entityMapping; |
|
375 | + return self::$_entityMapping; |
|
376 | 376 | } |
377 | 377 | } |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | public static function getEntityMapping() { |
298 | 298 | if (!is_null(self::$_entityMapping)) |
299 | 299 | { |
300 | - self::$_entityMapping = array ( |
|
301 | - 'Post' => array ( |
|
300 | + self::$_entityMapping = array( |
|
301 | + 'Post' => array( |
|
302 | 302 | '$MappedTable$' => 'wp_posts', |
303 | 303 | 'PostID' => 'ID', |
304 | 304 | 'Author' => 'post_author', |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | 'CommentCount' => 'comment_count' |
325 | 325 | ), |
326 | 326 | |
327 | - 'Tag' => array ( |
|
327 | + 'Tag' => array( |
|
328 | 328 | '$MappedTable$' => 'wp_terms', |
329 | 329 | 'TagID' =>'t.term_id', |
330 | 330 | 'Name' =>'t.name', |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | 'Description' =>'tt.description' |
333 | 333 | ), |
334 | 334 | |
335 | - 'Category' => array ( |
|
335 | + 'Category' => array( |
|
336 | 336 | '$MappedTable$' => 'wp_terms', |
337 | 337 | 'CategoryID' =>'t.term_id', |
338 | 338 | 'Name' =>'t.name', |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | 'Description' =>'tt.description' |
341 | 341 | ), |
342 | 342 | |
343 | - 'Comment' => array ( |
|
343 | + 'Comment' => array( |
|
344 | 344 | '$MappedTable$' => 'wp_comments', |
345 | 345 | 'CommentID', 'comment_id', |
346 | 346 | 'PostID', 'comment_post_id', |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | 'UserID', 'user_id' |
359 | 359 | ), |
360 | 360 | |
361 | - 'User' => array ( |
|
361 | + 'User' => array( |
|
362 | 362 | '$MappedTable$' => 'wp_users', |
363 | 363 | 'UserID' => 'ID', |
364 | 364 | 'Login' => 'user_login', |
@@ -172,7 +172,7 @@ |
||
172 | 172 | * |
173 | 173 | * @throws InvalidOperationException |
174 | 174 | * |
175 | - * @return NorthWindMetadata |
|
175 | + * @return SimpleMetadataProvider |
|
176 | 176 | */ |
177 | 177 | public static function create() |
178 | 178 | { |
@@ -76,7 +76,6 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @param ResourceSet $resourceSet The entity set whose |
78 | 78 | * entities needs to be fetched |
79 | - * @param string $filterOption Contains the filter condition |
|
80 | 79 | * @param string $select For future purpose,no need to pass it |
81 | 80 | * @param string $orderby For future purpose,no need to pass it |
82 | 81 | * @param string $top For future purpose,no need to pass it |
@@ -273,7 +272,6 @@ discard block |
||
273 | 272 | * the navigation property |
274 | 273 | * @param ResourceProperty $targetProperty The navigation property to be |
275 | 274 | * retrieved |
276 | - * @param string $filterOption Contains the filter condition |
|
277 | 275 | * @param string $select For future purpose,no need to pass it |
278 | 276 | * @param string $orderby For future purpose,no need to pass it |
279 | 277 | * @param string $top For future purpose,no need to pass it |
@@ -662,7 +660,7 @@ discard block |
||
662 | 660 | /** |
663 | 661 | * Serialize the mysql result array into Post objects |
664 | 662 | * |
665 | - * @param array(array) $result result of the mysql query |
|
663 | + * @param resource $result result of the mysql query |
|
666 | 664 | * |
667 | 665 | * @return array(Object) |
668 | 666 | */ |
@@ -681,7 +679,7 @@ discard block |
||
681 | 679 | * |
682 | 680 | * @param array $record each post row |
683 | 681 | * |
684 | - * @return object |
|
682 | + * @return Post |
|
685 | 683 | */ |
686 | 684 | private function _serializePost($record) |
687 | 685 | { |
@@ -741,7 +739,7 @@ discard block |
||
741 | 739 | /** |
742 | 740 | * Serialize the mysql result array into Tag objects |
743 | 741 | * |
744 | - * @param array(array) $result result of the mysql query |
|
742 | + * @param resource $result result of the mysql query |
|
745 | 743 | * |
746 | 744 | * @return array(Object) |
747 | 745 | */ |
@@ -760,7 +758,7 @@ discard block |
||
760 | 758 | * |
761 | 759 | * @param array $record each tag row |
762 | 760 | * |
763 | - * @return object |
|
761 | + * @return Tag |
|
764 | 762 | */ |
765 | 763 | private function _serializeTag($record) |
766 | 764 | { |
@@ -775,7 +773,7 @@ discard block |
||
775 | 773 | /** |
776 | 774 | * Serialize the mysql result array into Category objects |
777 | 775 | * |
778 | - * @param array(array) $result result of the mysql query |
|
776 | + * @param resource $result result of the mysql query |
|
779 | 777 | * |
780 | 778 | * @return array(Object) |
781 | 779 | */ |
@@ -794,7 +792,7 @@ discard block |
||
794 | 792 | * |
795 | 793 | * @param array $record each category row |
796 | 794 | * |
797 | - * @return object |
|
795 | + * @return Category |
|
798 | 796 | */ |
799 | 797 | private function _serializeCategory($record) |
800 | 798 | { |
@@ -809,7 +807,7 @@ discard block |
||
809 | 807 | /** |
810 | 808 | * Serialize the mysql result array into Comment objects |
811 | 809 | * |
812 | - * @param array(array) $result mysql query result |
|
810 | + * @param resource $result mysql query result |
|
813 | 811 | * |
814 | 812 | * @return array(Object) |
815 | 813 | */ |
@@ -828,7 +826,7 @@ discard block |
||
828 | 826 | * |
829 | 827 | * @param array $record each comment row |
830 | 828 | * |
831 | - * @return object |
|
829 | + * @return Comment |
|
832 | 830 | */ |
833 | 831 | private function _serializeComment($record) |
834 | 832 | { |
@@ -867,7 +865,7 @@ discard block |
||
867 | 865 | /** |
868 | 866 | * Serialize the mysql result array into User objects |
869 | 867 | * |
870 | - * @param array(array) $result result of the mysql query |
|
868 | + * @param resource $result result of the mysql query |
|
871 | 869 | * |
872 | 870 | * @return array(Object) |
873 | 871 | */ |
@@ -886,7 +884,7 @@ discard block |
||
886 | 884 | * |
887 | 885 | * @param array $record each user row |
888 | 886 | * |
889 | - * @return object |
|
887 | + * @return User |
|
890 | 888 | */ |
891 | 889 | private function _serializeUser($record) |
892 | 890 | { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->_connectionHandle = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true); |
44 | 44 | if ( $this->_connectionHandle ) { |
45 | 45 | } else { |
46 | - die(print_r(mysql_error(), true)); |
|
46 | + die(print_r(mysql_error(), true)); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | mysql_select_db(DB_NAME, $this->_connectionHandle); |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getExpressionProvider() |
66 | 66 | { |
67 | - if (is_null($this->_wordPressMySQLExpressionProvider)) { |
|
68 | - $this->_wordPressMySQLExpressionProvider = new WordPressDSExpressionProvider(); |
|
69 | - } |
|
67 | + if (is_null($this->_wordPressMySQLExpressionProvider)) { |
|
68 | + $this->_wordPressMySQLExpressionProvider = new WordPressDSExpressionProvider(); |
|
69 | + } |
|
70 | 70 | |
71 | - return $this->_wordPressMySQLExpressionProvider; |
|
71 | + return $this->_wordPressMySQLExpressionProvider; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | switch ($resourceSetName) { |
102 | 102 | case 'Posts': |
103 | 103 | $query = "SELECT * FROM `wp_posts` WHERE" |
104 | - ." wp_posts.post_type = 'post'" |
|
105 | - ." AND wp_posts.post_status = 'publish'"; |
|
104 | + ." wp_posts.post_type = 'post'" |
|
105 | + ." AND wp_posts.post_status = 'publish'"; |
|
106 | 106 | if ($filter !== null) { |
107 | 107 | $query .= " AND $filter"; |
108 | 108 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | break; |
112 | 112 | case 'Tags': |
113 | 113 | $query = "SELECT t.*, tt.description" |
114 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
115 | - ." ON tt.term_id = t.term_id" |
|
116 | - ." WHERE tt.taxonomy = 'post_tag'"; |
|
114 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
115 | + ." ON tt.term_id = t.term_id" |
|
116 | + ." WHERE tt.taxonomy = 'post_tag'"; |
|
117 | 117 | if ($filter !== null) { |
118 | 118 | $query .= " AND $filter"; |
119 | 119 | } |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | break; |
123 | 123 | case 'Categories': |
124 | 124 | $query = "SELECT t.*, tt.description" |
125 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
126 | - ." ON tt.term_id = t.term_id" |
|
127 | - ." WHERE tt.taxonomy = 'category'"; |
|
125 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
126 | + ." ON tt.term_id = t.term_id" |
|
127 | + ." WHERE tt.taxonomy = 'category'"; |
|
128 | 128 | if ($filter !== null) { |
129 | 129 | $query .= " AND $filter"; |
130 | 130 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | break; |
134 | 134 | case 'Comments': |
135 | 135 | $query = "SELECT * FROM `wp_comments` WHERE" |
136 | - ." wp_comments.comment_approved = 1"; |
|
136 | + ." wp_comments.comment_approved = 1"; |
|
137 | 137 | if ($filter !== null) { |
138 | 138 | $query .= " AND $filter"; |
139 | 139 | } |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | switch ($resourceSetName) { |
188 | 188 | case 'Posts': |
189 | 189 | $query = "SELECT * FROM `wp_posts` WHERE" |
190 | - ." wp_posts.post_type = 'post'" |
|
191 | - ." AND wp_posts.post_status = 'publish'" |
|
192 | - ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
190 | + ." wp_posts.post_type = 'post'" |
|
191 | + ." AND wp_posts.post_status = 'publish'" |
|
192 | + ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
193 | 193 | $stmt = mysql_query($query); |
194 | 194 | |
195 | 195 | //If resource not found return null to the library |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | break; |
203 | 203 | case 'Tags': |
204 | 204 | $query = "SELECT t.*, tt.description" |
205 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
206 | - ." ON tt.term_id = t.term_id" |
|
207 | - ." WHERE tt.taxonomy = 'post_tag'" |
|
208 | - ." AND t.term_id = ".$namedKeyValues['TagID'][0]; |
|
205 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
206 | + ." ON tt.term_id = t.term_id" |
|
207 | + ." WHERE tt.taxonomy = 'post_tag'" |
|
208 | + ." AND t.term_id = ".$namedKeyValues['TagID'][0]; |
|
209 | 209 | $stmt = mysql_query($query); |
210 | 210 | |
211 | 211 | //If resource not found return null to the library |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | break; |
219 | 219 | case 'Categories': |
220 | 220 | $query = "SELECT t.*, tt.description" |
221 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
222 | - ." ON tt.term_id = t.term_id" |
|
223 | - ." WHERE tt.taxonomy = 'category'" |
|
224 | - ." AND t.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
221 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
222 | + ." ON tt.term_id = t.term_id" |
|
223 | + ." WHERE tt.taxonomy = 'category'" |
|
224 | + ." AND t.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
225 | 225 | $stmt = mysql_query($query); |
226 | 226 | |
227 | 227 | //If resource not found return null to the library |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | break; |
235 | 235 | case 'Comments': |
236 | 236 | $query = "SELECT * FROM `wp_comments`" |
237 | - ." WHERE comment_approved = 1" |
|
238 | - ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
237 | + ." WHERE comment_approved = 1" |
|
238 | + ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
239 | 239 | $stmt = mysql_query($query); |
240 | 240 | |
241 | 241 | //If resource not found return null to the library |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | case ($srcClass == 'Post'): |
297 | 297 | if ($navigationPropName == 'Tags') { |
298 | 298 | $query = "SELECT t.*, tt.description" |
299 | - ." FROM wp_terms AS t" |
|
300 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
301 | - ." ON tt.term_id = t.term_id" |
|
302 | - ." INNER JOIN wp_term_relationships AS tr" |
|
303 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
304 | - ." WHERE tt.taxonomy IN ('post_tag')" |
|
305 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
299 | + ." FROM wp_terms AS t" |
|
300 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
301 | + ." ON tt.term_id = t.term_id" |
|
302 | + ." INNER JOIN wp_term_relationships AS tr" |
|
303 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
304 | + ." WHERE tt.taxonomy IN ('post_tag')" |
|
305 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
306 | 306 | if ($filter !== null) { |
307 | 307 | $query .= " AND $filter"; |
308 | 308 | } |
@@ -314,26 +314,26 @@ discard block |
||
314 | 314 | $result = $this->_serializeTags($stmt); |
315 | 315 | } elseif ($navigationPropName == 'Categories') { |
316 | 316 | $query = "SELECT t.*, tt.description" |
317 | - ." FROM wp_terms AS t" |
|
318 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
319 | - ." ON tt.term_id = t.term_id" |
|
320 | - ." INNER JOIN wp_term_relationships AS tr" |
|
321 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
322 | - ." WHERE tt.taxonomy IN ('category')" |
|
323 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
317 | + ." FROM wp_terms AS t" |
|
318 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
319 | + ." ON tt.term_id = t.term_id" |
|
320 | + ." INNER JOIN wp_term_relationships AS tr" |
|
321 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
322 | + ." WHERE tt.taxonomy IN ('category')" |
|
323 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
324 | 324 | if ($filter !== null) { |
325 | 325 | $query .= " AND $filter"; |
326 | 326 | } |
327 | 327 | $stmt = mysql_query($query); |
328 | 328 | if ( $stmt === false) { |
329 | - die(mysql_error()); |
|
329 | + die(mysql_error()); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $result = $this->_serializeCategories($stmt); |
333 | 333 | } else if ($navigationPropName == 'Comments') { |
334 | 334 | $query = "SELECT * FROM `wp_comments`" |
335 | - ." WHERE comment_approved = 1" |
|
336 | - ." AND comment_post_ID = $sourceEntityInstance->PostID"; |
|
335 | + ." WHERE comment_approved = 1" |
|
336 | + ." AND comment_post_ID = $sourceEntityInstance->PostID"; |
|
337 | 337 | if ($filter !== null) { |
338 | 338 | $query .= " AND $filter"; |
339 | 339 | } |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | case ($srcClass == 'Tag'): |
352 | 352 | if ($navigationPropName == 'Posts') { |
353 | 353 | $query = "SELECT p . *" |
354 | - ." FROM wp_posts AS p" |
|
355 | - ." INNER JOIN wp_term_relationships AS tr" |
|
356 | - ." ON p.ID = tr.object_id" |
|
357 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
358 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
359 | - ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
360 | - ." AND p.post_type = 'post'" |
|
361 | - ." AND p.post_status = 'publish'"; |
|
354 | + ." FROM wp_posts AS p" |
|
355 | + ." INNER JOIN wp_term_relationships AS tr" |
|
356 | + ." ON p.ID = tr.object_id" |
|
357 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
358 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
359 | + ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
360 | + ." AND p.post_type = 'post'" |
|
361 | + ." AND p.post_status = 'publish'"; |
|
362 | 362 | if ($filter !== null) { |
363 | 363 | $query .= " AND $filter"; |
364 | 364 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | die(mysql_error()); |
368 | 368 | } |
369 | 369 | |
370 | - $result = $this->_serializePosts($stmt); |
|
370 | + $result = $this->_serializePosts($stmt); |
|
371 | 371 | } else { |
372 | 372 | die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
373 | 373 | } |
@@ -376,14 +376,14 @@ discard block |
||
376 | 376 | case ($srcClass == 'Category'): |
377 | 377 | if ($navigationPropName == 'Posts') { |
378 | 378 | $query = "SELECT p . *" |
379 | - ." FROM wp_posts AS p" |
|
380 | - ." INNER JOIN wp_term_relationships AS tr" |
|
381 | - ." ON p.ID = tr.object_id" |
|
382 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
383 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
384 | - ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
385 | - ." AND p.post_type = 'post'" |
|
386 | - ." AND p.post_status = 'publish'"; |
|
379 | + ." FROM wp_posts AS p" |
|
380 | + ." INNER JOIN wp_term_relationships AS tr" |
|
381 | + ." ON p.ID = tr.object_id" |
|
382 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
383 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
384 | + ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
385 | + ." AND p.post_type = 'post'" |
|
386 | + ." AND p.post_status = 'publish'"; |
|
387 | 387 | if ($filter !== null) { |
388 | 388 | $query .= " AND $filter"; |
389 | 389 | } |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | case ($srcClass == 'User'): |
406 | 406 | if ($navigationPropName == 'Posts') { |
407 | 407 | $query = "SELECT * FROM `wp_posts` WHERE" |
408 | - ." wp_posts.post_type = 'post'" |
|
409 | - ." AND wp_posts.post_status = 'publish'" |
|
410 | - ." AND wp_posts.post_author = $sourceEntityInstance->UserID"; |
|
408 | + ." wp_posts.post_type = 'post'" |
|
409 | + ." AND wp_posts.post_status = 'publish'" |
|
410 | + ." AND wp_posts.post_author = $sourceEntityInstance->UserID"; |
|
411 | 411 | if ($filter !== null) { |
412 | 412 | $query .= " AND $filter"; |
413 | 413 | } |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | $result = $this->_serializePosts($stmt); |
420 | 420 | } elseif ($navigationPropName == 'Comments') { |
421 | 421 | $query = "SELECT * FROM `wp_comments`" |
422 | - ." WHERE comment_approved = 1" |
|
423 | - ." AND wp_comments.user_id = $sourceEntityInstance->UserID"; |
|
422 | + ." WHERE comment_approved = 1" |
|
423 | + ." AND wp_comments.user_id = $sourceEntityInstance->UserID"; |
|
424 | 424 | if ($filter !== null) { |
425 | 425 | $query .= " AND $filter"; |
426 | 426 | } |
@@ -476,33 +476,33 @@ discard block |
||
476 | 476 | case ($srcClass == 'Post'): |
477 | 477 | if ($navigationPropName == 'Tags') { |
478 | 478 | $query = "SELECT t.*, tt.description" |
479 | - ." FROM wp_terms AS t" |
|
480 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
481 | - ." ON tt.term_id = t.term_id" |
|
482 | - ." INNER JOIN wp_term_relationships AS tr" |
|
483 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
484 | - ." WHERE tt.taxonomy IN ('post_tag')" |
|
485 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
486 | - ." AND tt.term_id = ".$namedKeyValues['TagID'][0]; |
|
479 | + ." FROM wp_terms AS t" |
|
480 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
481 | + ." ON tt.term_id = t.term_id" |
|
482 | + ." INNER JOIN wp_term_relationships AS tr" |
|
483 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
484 | + ." WHERE tt.taxonomy IN ('post_tag')" |
|
485 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
486 | + ." AND tt.term_id = ".$namedKeyValues['TagID'][0]; |
|
487 | 487 | $stmt = mysql_query($query); |
488 | 488 | $result = $this->_serializeTags($stmt); |
489 | 489 | } elseif ($navigationPropName == 'Categories') { |
490 | 490 | $query = "SELECT t.*, tt.description" |
491 | - ." FROM wp_terms AS t" |
|
492 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
493 | - ." ON tt.term_id = t.term_id" |
|
494 | - ." INNER JOIN wp_term_relationships AS tr" |
|
495 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
496 | - ." WHERE tt.taxonomy IN ('category')" |
|
497 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
498 | - ." AND tt.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
491 | + ." FROM wp_terms AS t" |
|
492 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
493 | + ." ON tt.term_id = t.term_id" |
|
494 | + ." INNER JOIN wp_term_relationships AS tr" |
|
495 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
496 | + ." WHERE tt.taxonomy IN ('category')" |
|
497 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
498 | + ." AND tt.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
499 | 499 | $stmt = mysql_query($query); |
500 | 500 | $result = $this->_serializeCategories($stmt); |
501 | 501 | } else if ($navigationPropName == 'Comments') { |
502 | 502 | $query = "SELECT * FROM `wp_comments`" |
503 | - ." WHERE comment_approved = 1" |
|
504 | - ." AND comment_post_ID = $sourceEntityInstance->PostID" |
|
505 | - ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
503 | + ." WHERE comment_approved = 1" |
|
504 | + ." AND comment_post_ID = $sourceEntityInstance->PostID" |
|
505 | + ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
506 | 506 | $stmt = mysql_query($query); |
507 | 507 | $result = $this->_serializeComments($stmt); |
508 | 508 | } else { |
@@ -513,15 +513,15 @@ discard block |
||
513 | 513 | case ($srcClass == 'Tag'): |
514 | 514 | if ($navigationPropName == 'Posts') { |
515 | 515 | $query = "SELECT p . *" |
516 | - ." FROM wp_posts AS p" |
|
517 | - ." INNER JOIN wp_term_relationships AS tr" |
|
518 | - ." ON p.ID = tr.object_id" |
|
519 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
520 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
521 | - ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
522 | - ." AND p.post_type = 'post'" |
|
523 | - ." AND p.post_status = 'publish'" |
|
524 | - ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
516 | + ." FROM wp_posts AS p" |
|
517 | + ." INNER JOIN wp_term_relationships AS tr" |
|
518 | + ." ON p.ID = tr.object_id" |
|
519 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
520 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
521 | + ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
522 | + ." AND p.post_type = 'post'" |
|
523 | + ." AND p.post_status = 'publish'" |
|
524 | + ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
525 | 525 | $stmt = mysql_query($query); |
526 | 526 | $result = $this->_serializePosts($stmt); |
527 | 527 | } else { |
@@ -532,15 +532,15 @@ discard block |
||
532 | 532 | case ($srcClass == 'Category'): |
533 | 533 | if ($navigationPropName == 'Posts') { |
534 | 534 | $query = "SELECT p . *" |
535 | - ." FROM wp_posts AS p" |
|
536 | - ." INNER JOIN wp_term_relationships AS tr" |
|
537 | - ." ON p.ID = tr.object_id" |
|
538 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
539 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
540 | - ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
541 | - ." AND p.post_type = 'post'" |
|
542 | - ." AND p.post_status = 'publish'" |
|
543 | - ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
535 | + ." FROM wp_posts AS p" |
|
536 | + ." INNER JOIN wp_term_relationships AS tr" |
|
537 | + ." ON p.ID = tr.object_id" |
|
538 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
539 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
540 | + ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
541 | + ." AND p.post_type = 'post'" |
|
542 | + ." AND p.post_status = 'publish'" |
|
543 | + ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
544 | 544 | $stmt = mysql_query($query); |
545 | 545 | $result = $this->_serializePosts($stmt); |
546 | 546 | } else { |
@@ -554,22 +554,22 @@ discard block |
||
554 | 554 | |
555 | 555 | case ($srcClass == 'User'): |
556 | 556 | if ($navigationPropName == 'Posts') { |
557 | - $query = "SELECT * FROM `wp_posts` WHERE" |
|
557 | + $query = "SELECT * FROM `wp_posts` WHERE" |
|
558 | 558 | ." wp_posts.post_type = 'post'" |
559 | 559 | ." AND wp_posts.post_status = 'publish'" |
560 | 560 | ." AND wp_posts.post_author = $sourceEntityInstance->UserID" |
561 | 561 | ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
562 | - $stmt = mysql_query($query); |
|
563 | - $result = $this->_serializePosts($stmt); |
|
562 | + $stmt = mysql_query($query); |
|
563 | + $result = $this->_serializePosts($stmt); |
|
564 | 564 | } elseif ($navigationPropName == 'Comments') { |
565 | - $query = "SELECT * FROM `wp_comments`" |
|
566 | - ." WHERE comment_approved = 1" |
|
567 | - ." AND wp_comments.user_id = $sourceEntityInstance->UserID" |
|
568 | - ." AND wp_comments.comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
569 | - $stmt = mysql_query($query); |
|
570 | - $result = $this->_serializeComments($stmt); |
|
565 | + $query = "SELECT * FROM `wp_comments`" |
|
566 | + ." WHERE comment_approved = 1" |
|
567 | + ." AND wp_comments.user_id = $sourceEntityInstance->UserID" |
|
568 | + ." AND wp_comments.comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
569 | + $stmt = mysql_query($query); |
|
570 | + $result = $this->_serializeComments($stmt); |
|
571 | 571 | } else { |
572 | - die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
572 | + die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
573 | 573 | } |
574 | 574 | break; |
575 | 575 | } |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | |
636 | 636 | } elseif ($navigationPropName == 'Post') { |
637 | 637 | $query = "SELECT * FROM `wp_posts` WHERE" |
638 | - ." wp_posts.post_type = 'post'" |
|
639 | - ." AND wp_posts.post_status = 'publish'" |
|
640 | - ." AND wp_posts.ID = $sourceEntityInstance->PostID"; |
|
638 | + ." wp_posts.post_type = 'post'" |
|
639 | + ." AND wp_posts.post_status = 'publish'" |
|
640 | + ." AND wp_posts.ID = $sourceEntityInstance->PostID"; |
|
641 | 641 | $stmt = mysql_query($query); |
642 | 642 | if ( $stmt === false) { |
643 | 643 | die(mysql_error()); |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | { |
671 | 671 | $posts = array(); |
672 | 672 | while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
673 | - $posts[] = $this->_serializePost($record); |
|
673 | + $posts[] = $this->_serializePost($record); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | return $posts; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | { |
750 | 750 | $tags = array(); |
751 | 751 | while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
752 | - $tags[] = $this->_serializeTag($record); |
|
752 | + $tags[] = $this->_serializeTag($record); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | return $tags; |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | { |
784 | 784 | $cats = array(); |
785 | 785 | while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
786 | - $cats[] = $this->_serializeCategory($record); |
|
786 | + $cats[] = $this->_serializeCategory($record); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | return $cats; |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | { |
818 | 818 | $comments = array(); |
819 | 819 | while ( $record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
820 | - $comments[] = $this->_serializeComment($record); |
|
820 | + $comments[] = $this->_serializeComment($record); |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | return $comments; |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | { |
876 | 876 | $users = array(); |
877 | 877 | while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
878 | - $users[] = $this->_serializeUser($record); |
|
878 | + $users[] = $this->_serializeUser($record); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | return $users; |
@@ -99,57 +99,57 @@ discard block |
||
99 | 99 | |
100 | 100 | $returnResult = array(); |
101 | 101 | switch ($resourceSetName) { |
102 | - case 'Posts': |
|
103 | - $query = "SELECT * FROM `wp_posts` WHERE" |
|
104 | - ." wp_posts.post_type = 'post'" |
|
105 | - ." AND wp_posts.post_status = 'publish'"; |
|
106 | - if ($filter !== null) { |
|
107 | - $query .= " AND $filter"; |
|
108 | - } |
|
109 | - $stmt = mysql_query($query); |
|
110 | - $returnResult = $this->_serializePosts($stmt); |
|
111 | - break; |
|
112 | - case 'Tags': |
|
113 | - $query = "SELECT t.*, tt.description" |
|
114 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
115 | - ." ON tt.term_id = t.term_id" |
|
116 | - ." WHERE tt.taxonomy = 'post_tag'"; |
|
117 | - if ($filter !== null) { |
|
118 | - $query .= " AND $filter"; |
|
119 | - } |
|
120 | - $stmt = mysql_query($query); |
|
121 | - $returnResult = $this->_serializeTags($stmt); |
|
122 | - break; |
|
123 | - case 'Categories': |
|
124 | - $query = "SELECT t.*, tt.description" |
|
125 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
126 | - ." ON tt.term_id = t.term_id" |
|
127 | - ." WHERE tt.taxonomy = 'category'"; |
|
128 | - if ($filter !== null) { |
|
129 | - $query .= " AND $filter"; |
|
130 | - } |
|
131 | - $stmt = mysql_query($query); |
|
132 | - $returnResult = $this->_serializeCategories($stmt); |
|
133 | - break; |
|
134 | - case 'Comments': |
|
135 | - $query = "SELECT * FROM `wp_comments` WHERE" |
|
136 | - ." wp_comments.comment_approved = 1"; |
|
137 | - if ($filter !== null) { |
|
138 | - $query .= " AND $filter"; |
|
139 | - } |
|
140 | - $stmt = mysql_query($query); |
|
141 | - $returnResult = $this->_serializeComments($stmt); |
|
142 | - break; |
|
143 | - case 'Users': |
|
144 | - $query = "SELECT * FROM `wp_users`"; |
|
145 | - //print "<br>Filter:".$filter; |
|
146 | - if ($filter !== null) { |
|
147 | - $query .= " AND $filter"; |
|
148 | - } |
|
149 | - $stmt = mysql_query($query); |
|
150 | - //$data = mysql_fetch_assoc($stmt); |
|
151 | - $returnResult = $this->_serializeUsers($stmt); |
|
152 | - break; |
|
102 | + case 'Posts': |
|
103 | + $query = "SELECT * FROM `wp_posts` WHERE" |
|
104 | + ." wp_posts.post_type = 'post'" |
|
105 | + ." AND wp_posts.post_status = 'publish'"; |
|
106 | + if ($filter !== null) { |
|
107 | + $query .= " AND $filter"; |
|
108 | + } |
|
109 | + $stmt = mysql_query($query); |
|
110 | + $returnResult = $this->_serializePosts($stmt); |
|
111 | + break; |
|
112 | + case 'Tags': |
|
113 | + $query = "SELECT t.*, tt.description" |
|
114 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
115 | + ." ON tt.term_id = t.term_id" |
|
116 | + ." WHERE tt.taxonomy = 'post_tag'"; |
|
117 | + if ($filter !== null) { |
|
118 | + $query .= " AND $filter"; |
|
119 | + } |
|
120 | + $stmt = mysql_query($query); |
|
121 | + $returnResult = $this->_serializeTags($stmt); |
|
122 | + break; |
|
123 | + case 'Categories': |
|
124 | + $query = "SELECT t.*, tt.description" |
|
125 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
126 | + ." ON tt.term_id = t.term_id" |
|
127 | + ." WHERE tt.taxonomy = 'category'"; |
|
128 | + if ($filter !== null) { |
|
129 | + $query .= " AND $filter"; |
|
130 | + } |
|
131 | + $stmt = mysql_query($query); |
|
132 | + $returnResult = $this->_serializeCategories($stmt); |
|
133 | + break; |
|
134 | + case 'Comments': |
|
135 | + $query = "SELECT * FROM `wp_comments` WHERE" |
|
136 | + ." wp_comments.comment_approved = 1"; |
|
137 | + if ($filter !== null) { |
|
138 | + $query .= " AND $filter"; |
|
139 | + } |
|
140 | + $stmt = mysql_query($query); |
|
141 | + $returnResult = $this->_serializeComments($stmt); |
|
142 | + break; |
|
143 | + case 'Users': |
|
144 | + $query = "SELECT * FROM `wp_users`"; |
|
145 | + //print "<br>Filter:".$filter; |
|
146 | + if ($filter !== null) { |
|
147 | + $query .= " AND $filter"; |
|
148 | + } |
|
149 | + $stmt = mysql_query($query); |
|
150 | + //$data = mysql_fetch_assoc($stmt); |
|
151 | + $returnResult = $this->_serializeUsers($stmt); |
|
152 | + break; |
|
153 | 153 | } |
154 | 154 | mysql_free_result($stmt); |
155 | 155 | return $returnResult; |
@@ -185,79 +185,79 @@ discard block |
||
185 | 185 | $conditionStr = implode(' AND ', $keys); |
186 | 186 | |
187 | 187 | switch ($resourceSetName) { |
188 | - case 'Posts': |
|
189 | - $query = "SELECT * FROM `wp_posts` WHERE" |
|
190 | - ." wp_posts.post_type = 'post'" |
|
191 | - ." AND wp_posts.post_status = 'publish'" |
|
192 | - ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
193 | - $stmt = mysql_query($query); |
|
188 | + case 'Posts': |
|
189 | + $query = "SELECT * FROM `wp_posts` WHERE" |
|
190 | + ." wp_posts.post_type = 'post'" |
|
191 | + ." AND wp_posts.post_status = 'publish'" |
|
192 | + ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
193 | + $stmt = mysql_query($query); |
|
194 | 194 | |
195 | - //If resource not found return null to the library |
|
196 | - if (!mysql_num_rows($stmt)) { |
|
197 | - return null; |
|
198 | - } |
|
195 | + //If resource not found return null to the library |
|
196 | + if (!mysql_num_rows($stmt)) { |
|
197 | + return null; |
|
198 | + } |
|
199 | 199 | |
200 | - $data = mysql_fetch_assoc($stmt); |
|
201 | - $result = $this->_serializePost($data); |
|
202 | - break; |
|
203 | - case 'Tags': |
|
204 | - $query = "SELECT t.*, tt.description" |
|
205 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
206 | - ." ON tt.term_id = t.term_id" |
|
207 | - ." WHERE tt.taxonomy = 'post_tag'" |
|
208 | - ." AND t.term_id = ".$namedKeyValues['TagID'][0]; |
|
209 | - $stmt = mysql_query($query); |
|
200 | + $data = mysql_fetch_assoc($stmt); |
|
201 | + $result = $this->_serializePost($data); |
|
202 | + break; |
|
203 | + case 'Tags': |
|
204 | + $query = "SELECT t.*, tt.description" |
|
205 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
206 | + ." ON tt.term_id = t.term_id" |
|
207 | + ." WHERE tt.taxonomy = 'post_tag'" |
|
208 | + ." AND t.term_id = ".$namedKeyValues['TagID'][0]; |
|
209 | + $stmt = mysql_query($query); |
|
210 | 210 | |
211 | - //If resource not found return null to the library |
|
212 | - if (!mysql_num_rows($stmt)) { |
|
213 | - return null; |
|
214 | - } |
|
211 | + //If resource not found return null to the library |
|
212 | + if (!mysql_num_rows($stmt)) { |
|
213 | + return null; |
|
214 | + } |
|
215 | 215 | |
216 | - $data = mysql_fetch_assoc($stmt); |
|
217 | - $result = $this->_serializeTag($data); |
|
218 | - break; |
|
219 | - case 'Categories': |
|
220 | - $query = "SELECT t.*, tt.description" |
|
221 | - ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
222 | - ." ON tt.term_id = t.term_id" |
|
223 | - ." WHERE tt.taxonomy = 'category'" |
|
224 | - ." AND t.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
225 | - $stmt = mysql_query($query); |
|
216 | + $data = mysql_fetch_assoc($stmt); |
|
217 | + $result = $this->_serializeTag($data); |
|
218 | + break; |
|
219 | + case 'Categories': |
|
220 | + $query = "SELECT t.*, tt.description" |
|
221 | + ." FROM `wp_terms` AS t INNER JOIN `wp_term_taxonomy` as tt" |
|
222 | + ." ON tt.term_id = t.term_id" |
|
223 | + ." WHERE tt.taxonomy = 'category'" |
|
224 | + ." AND t.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
225 | + $stmt = mysql_query($query); |
|
226 | 226 | |
227 | - //If resource not found return null to the library |
|
228 | - if (!mysql_num_rows($stmt)) { |
|
229 | - return null; |
|
230 | - } |
|
227 | + //If resource not found return null to the library |
|
228 | + if (!mysql_num_rows($stmt)) { |
|
229 | + return null; |
|
230 | + } |
|
231 | 231 | |
232 | - $data = mysql_fetch_assoc($stmt); |
|
233 | - $result = $this->_serializeCategory($data); |
|
234 | - break; |
|
235 | - case 'Comments': |
|
236 | - $query = "SELECT * FROM `wp_comments`" |
|
237 | - ." WHERE comment_approved = 1" |
|
238 | - ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
239 | - $stmt = mysql_query($query); |
|
232 | + $data = mysql_fetch_assoc($stmt); |
|
233 | + $result = $this->_serializeCategory($data); |
|
234 | + break; |
|
235 | + case 'Comments': |
|
236 | + $query = "SELECT * FROM `wp_comments`" |
|
237 | + ." WHERE comment_approved = 1" |
|
238 | + ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
239 | + $stmt = mysql_query($query); |
|
240 | 240 | |
241 | - //If resource not found return null to the library |
|
242 | - if (!mysql_num_rows($stmt)) { |
|
243 | - return null; |
|
244 | - } |
|
241 | + //If resource not found return null to the library |
|
242 | + if (!mysql_num_rows($stmt)) { |
|
243 | + return null; |
|
244 | + } |
|
245 | 245 | |
246 | - $data = mysql_fetch_assoc($stmt); |
|
247 | - $result = $this->_serializeComment($data); |
|
248 | - break; |
|
249 | - case 'Users': |
|
250 | - $query = "SELECT * FROM `wp_users` WHERE ID = ".$namedKeyValues['UserID'][0]; |
|
251 | - $stmt = mysql_query($query); |
|
246 | + $data = mysql_fetch_assoc($stmt); |
|
247 | + $result = $this->_serializeComment($data); |
|
248 | + break; |
|
249 | + case 'Users': |
|
250 | + $query = "SELECT * FROM `wp_users` WHERE ID = ".$namedKeyValues['UserID'][0]; |
|
251 | + $stmt = mysql_query($query); |
|
252 | 252 | |
253 | - //If resource not found return null to the library |
|
254 | - if (!mysql_num_rows($stmt)) { |
|
255 | - return null; |
|
256 | - } |
|
253 | + //If resource not found return null to the library |
|
254 | + if (!mysql_num_rows($stmt)) { |
|
255 | + return null; |
|
256 | + } |
|
257 | 257 | |
258 | - $data = mysql_fetch_assoc($stmt); |
|
259 | - $result = $this->_serializeUser($data); |
|
260 | - break; |
|
258 | + $data = mysql_fetch_assoc($stmt); |
|
259 | + $result = $this->_serializeUser($data); |
|
260 | + break; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | mysql_free_result($stmt); |
@@ -293,147 +293,147 @@ discard block |
||
293 | 293 | $navigationPropName = $targetProperty->getName(); |
294 | 294 | |
295 | 295 | switch (true) { |
296 | - case ($srcClass == 'Post'): |
|
297 | - if ($navigationPropName == 'Tags') { |
|
298 | - $query = "SELECT t.*, tt.description" |
|
299 | - ." FROM wp_terms AS t" |
|
300 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
301 | - ." ON tt.term_id = t.term_id" |
|
302 | - ." INNER JOIN wp_term_relationships AS tr" |
|
303 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
304 | - ." WHERE tt.taxonomy IN ('post_tag')" |
|
305 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
306 | - if ($filter !== null) { |
|
307 | - $query .= " AND $filter"; |
|
308 | - } |
|
309 | - $stmt = mysql_query($query); |
|
310 | - if ( $stmt === false) { |
|
311 | - die(mysql_error()); |
|
312 | - } |
|
296 | + case ($srcClass == 'Post'): |
|
297 | + if ($navigationPropName == 'Tags') { |
|
298 | + $query = "SELECT t.*, tt.description" |
|
299 | + ." FROM wp_terms AS t" |
|
300 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
301 | + ." ON tt.term_id = t.term_id" |
|
302 | + ." INNER JOIN wp_term_relationships AS tr" |
|
303 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
304 | + ." WHERE tt.taxonomy IN ('post_tag')" |
|
305 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
306 | + if ($filter !== null) { |
|
307 | + $query .= " AND $filter"; |
|
308 | + } |
|
309 | + $stmt = mysql_query($query); |
|
310 | + if ( $stmt === false) { |
|
311 | + die(mysql_error()); |
|
312 | + } |
|
313 | 313 | |
314 | - $result = $this->_serializeTags($stmt); |
|
315 | - } elseif ($navigationPropName == 'Categories') { |
|
316 | - $query = "SELECT t.*, tt.description" |
|
317 | - ." FROM wp_terms AS t" |
|
318 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
319 | - ." ON tt.term_id = t.term_id" |
|
320 | - ." INNER JOIN wp_term_relationships AS tr" |
|
321 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
322 | - ." WHERE tt.taxonomy IN ('category')" |
|
323 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
324 | - if ($filter !== null) { |
|
325 | - $query .= " AND $filter"; |
|
326 | - } |
|
327 | - $stmt = mysql_query($query); |
|
328 | - if ( $stmt === false) { |
|
329 | - die(mysql_error()); |
|
330 | - } |
|
314 | + $result = $this->_serializeTags($stmt); |
|
315 | + } elseif ($navigationPropName == 'Categories') { |
|
316 | + $query = "SELECT t.*, tt.description" |
|
317 | + ." FROM wp_terms AS t" |
|
318 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
319 | + ." ON tt.term_id = t.term_id" |
|
320 | + ." INNER JOIN wp_term_relationships AS tr" |
|
321 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
322 | + ." WHERE tt.taxonomy IN ('category')" |
|
323 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)"; |
|
324 | + if ($filter !== null) { |
|
325 | + $query .= " AND $filter"; |
|
326 | + } |
|
327 | + $stmt = mysql_query($query); |
|
328 | + if ( $stmt === false) { |
|
329 | + die(mysql_error()); |
|
330 | + } |
|
331 | 331 | |
332 | - $result = $this->_serializeCategories($stmt); |
|
333 | - } else if ($navigationPropName == 'Comments') { |
|
334 | - $query = "SELECT * FROM `wp_comments`" |
|
335 | - ." WHERE comment_approved = 1" |
|
336 | - ." AND comment_post_ID = $sourceEntityInstance->PostID"; |
|
337 | - if ($filter !== null) { |
|
338 | - $query .= " AND $filter"; |
|
339 | - } |
|
340 | - $stmt = mysql_query($query); |
|
341 | - if ( $stmt === false) { |
|
342 | - die(mysql_error()); |
|
343 | - } |
|
332 | + $result = $this->_serializeCategories($stmt); |
|
333 | + } else if ($navigationPropName == 'Comments') { |
|
334 | + $query = "SELECT * FROM `wp_comments`" |
|
335 | + ." WHERE comment_approved = 1" |
|
336 | + ." AND comment_post_ID = $sourceEntityInstance->PostID"; |
|
337 | + if ($filter !== null) { |
|
338 | + $query .= " AND $filter"; |
|
339 | + } |
|
340 | + $stmt = mysql_query($query); |
|
341 | + if ( $stmt === false) { |
|
342 | + die(mysql_error()); |
|
343 | + } |
|
344 | 344 | |
345 | - $result = $this->_serializeComments($stmt); |
|
346 | - } else { |
|
347 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
348 | - } |
|
349 | - break; |
|
350 | - |
|
351 | - case ($srcClass == 'Tag'): |
|
352 | - if ($navigationPropName == 'Posts') { |
|
353 | - $query = "SELECT p . *" |
|
354 | - ." FROM wp_posts AS p" |
|
355 | - ." INNER JOIN wp_term_relationships AS tr" |
|
356 | - ." ON p.ID = tr.object_id" |
|
357 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
358 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
359 | - ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
360 | - ." AND p.post_type = 'post'" |
|
361 | - ." AND p.post_status = 'publish'"; |
|
362 | - if ($filter !== null) { |
|
363 | - $query .= " AND $filter"; |
|
364 | - } |
|
365 | - $stmt = mysql_query($query); |
|
366 | - if ( $stmt === false) { |
|
367 | - die(mysql_error()); |
|
345 | + $result = $this->_serializeComments($stmt); |
|
346 | + } else { |
|
347 | + die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
368 | 348 | } |
349 | + break; |
|
350 | + |
|
351 | + case ($srcClass == 'Tag'): |
|
352 | + if ($navigationPropName == 'Posts') { |
|
353 | + $query = "SELECT p . *" |
|
354 | + ." FROM wp_posts AS p" |
|
355 | + ." INNER JOIN wp_term_relationships AS tr" |
|
356 | + ." ON p.ID = tr.object_id" |
|
357 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
358 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
359 | + ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
360 | + ." AND p.post_type = 'post'" |
|
361 | + ." AND p.post_status = 'publish'"; |
|
362 | + if ($filter !== null) { |
|
363 | + $query .= " AND $filter"; |
|
364 | + } |
|
365 | + $stmt = mysql_query($query); |
|
366 | + if ( $stmt === false) { |
|
367 | + die(mysql_error()); |
|
368 | + } |
|
369 | 369 | |
370 | - $result = $this->_serializePosts($stmt); |
|
371 | - } else { |
|
372 | - die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
373 | - } |
|
374 | - break; |
|
375 | - |
|
376 | - case ($srcClass == 'Category'): |
|
377 | - if ($navigationPropName == 'Posts') { |
|
378 | - $query = "SELECT p . *" |
|
379 | - ." FROM wp_posts AS p" |
|
380 | - ." INNER JOIN wp_term_relationships AS tr" |
|
381 | - ." ON p.ID = tr.object_id" |
|
382 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
383 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
384 | - ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
385 | - ." AND p.post_type = 'post'" |
|
386 | - ." AND p.post_status = 'publish'"; |
|
387 | - if ($filter !== null) { |
|
388 | - $query .= " AND $filter"; |
|
389 | - } |
|
390 | - $stmt = mysql_query($query); |
|
391 | - if ( $stmt === false) { |
|
392 | - die(mysql_error()); |
|
370 | + $result = $this->_serializePosts($stmt); |
|
371 | + } else { |
|
372 | + die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
393 | 373 | } |
374 | + break; |
|
375 | + |
|
376 | + case ($srcClass == 'Category'): |
|
377 | + if ($navigationPropName == 'Posts') { |
|
378 | + $query = "SELECT p . *" |
|
379 | + ." FROM wp_posts AS p" |
|
380 | + ." INNER JOIN wp_term_relationships AS tr" |
|
381 | + ." ON p.ID = tr.object_id" |
|
382 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
383 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
384 | + ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
385 | + ." AND p.post_type = 'post'" |
|
386 | + ." AND p.post_status = 'publish'"; |
|
387 | + if ($filter !== null) { |
|
388 | + $query .= " AND $filter"; |
|
389 | + } |
|
390 | + $stmt = mysql_query($query); |
|
391 | + if ( $stmt === false) { |
|
392 | + die(mysql_error()); |
|
393 | + } |
|
394 | 394 | |
395 | - $result = $this->_serializePosts($stmt); |
|
396 | - } else { |
|
397 | - die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
398 | - } |
|
399 | - break; |
|
395 | + $result = $this->_serializePosts($stmt); |
|
396 | + } else { |
|
397 | + die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
398 | + } |
|
399 | + break; |
|
400 | 400 | |
401 | - case ($srcClass == 'Comment'): |
|
402 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
403 | - break; |
|
401 | + case ($srcClass == 'Comment'): |
|
402 | + die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
403 | + break; |
|
404 | 404 | |
405 | - case ($srcClass == 'User'): |
|
406 | - if ($navigationPropName == 'Posts') { |
|
407 | - $query = "SELECT * FROM `wp_posts` WHERE" |
|
408 | - ." wp_posts.post_type = 'post'" |
|
409 | - ." AND wp_posts.post_status = 'publish'" |
|
410 | - ." AND wp_posts.post_author = $sourceEntityInstance->UserID"; |
|
411 | - if ($filter !== null) { |
|
412 | - $query .= " AND $filter"; |
|
413 | - } |
|
414 | - $stmt = mysql_query($query); |
|
415 | - if ( $stmt === false) { |
|
416 | - die(mysql_error()); |
|
417 | - } |
|
405 | + case ($srcClass == 'User'): |
|
406 | + if ($navigationPropName == 'Posts') { |
|
407 | + $query = "SELECT * FROM `wp_posts` WHERE" |
|
408 | + ." wp_posts.post_type = 'post'" |
|
409 | + ." AND wp_posts.post_status = 'publish'" |
|
410 | + ." AND wp_posts.post_author = $sourceEntityInstance->UserID"; |
|
411 | + if ($filter !== null) { |
|
412 | + $query .= " AND $filter"; |
|
413 | + } |
|
414 | + $stmt = mysql_query($query); |
|
415 | + if ( $stmt === false) { |
|
416 | + die(mysql_error()); |
|
417 | + } |
|
418 | 418 | |
419 | - $result = $this->_serializePosts($stmt); |
|
420 | - } elseif ($navigationPropName == 'Comments') { |
|
421 | - $query = "SELECT * FROM `wp_comments`" |
|
422 | - ." WHERE comment_approved = 1" |
|
423 | - ." AND wp_comments.user_id = $sourceEntityInstance->UserID"; |
|
424 | - if ($filter !== null) { |
|
425 | - $query .= " AND $filter"; |
|
426 | - } |
|
427 | - $stmt = mysql_query($query); |
|
428 | - if ( $stmt === false) { |
|
429 | - die(mysql_error()); |
|
430 | - } |
|
419 | + $result = $this->_serializePosts($stmt); |
|
420 | + } elseif ($navigationPropName == 'Comments') { |
|
421 | + $query = "SELECT * FROM `wp_comments`" |
|
422 | + ." WHERE comment_approved = 1" |
|
423 | + ." AND wp_comments.user_id = $sourceEntityInstance->UserID"; |
|
424 | + if ($filter !== null) { |
|
425 | + $query .= " AND $filter"; |
|
426 | + } |
|
427 | + $stmt = mysql_query($query); |
|
428 | + if ( $stmt === false) { |
|
429 | + die(mysql_error()); |
|
430 | + } |
|
431 | 431 | |
432 | - $result = $this->_serializeComments($stmt); |
|
433 | - } else { |
|
434 | - die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
435 | - } |
|
436 | - break; |
|
432 | + $result = $this->_serializeComments($stmt); |
|
433 | + } else { |
|
434 | + die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
435 | + } |
|
436 | + break; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | mysql_free_result($stmt); |
@@ -473,105 +473,105 @@ discard block |
||
473 | 473 | $conditionStr = implode(' AND ', $keys); |
474 | 474 | |
475 | 475 | switch (true) { |
476 | - case ($srcClass == 'Post'): |
|
477 | - if ($navigationPropName == 'Tags') { |
|
478 | - $query = "SELECT t.*, tt.description" |
|
479 | - ." FROM wp_terms AS t" |
|
480 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
481 | - ." ON tt.term_id = t.term_id" |
|
482 | - ." INNER JOIN wp_term_relationships AS tr" |
|
483 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
484 | - ." WHERE tt.taxonomy IN ('post_tag')" |
|
485 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
486 | - ." AND tt.term_id = ".$namedKeyValues['TagID'][0]; |
|
487 | - $stmt = mysql_query($query); |
|
488 | - $result = $this->_serializeTags($stmt); |
|
489 | - } elseif ($navigationPropName == 'Categories') { |
|
490 | - $query = "SELECT t.*, tt.description" |
|
491 | - ." FROM wp_terms AS t" |
|
492 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
493 | - ." ON tt.term_id = t.term_id" |
|
494 | - ." INNER JOIN wp_term_relationships AS tr" |
|
495 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
496 | - ." WHERE tt.taxonomy IN ('category')" |
|
497 | - ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
498 | - ." AND tt.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
499 | - $stmt = mysql_query($query); |
|
500 | - $result = $this->_serializeCategories($stmt); |
|
501 | - } else if ($navigationPropName == 'Comments') { |
|
502 | - $query = "SELECT * FROM `wp_comments`" |
|
503 | - ." WHERE comment_approved = 1" |
|
504 | - ." AND comment_post_ID = $sourceEntityInstance->PostID" |
|
505 | - ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
506 | - $stmt = mysql_query($query); |
|
507 | - $result = $this->_serializeComments($stmt); |
|
508 | - } else { |
|
509 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
510 | - } |
|
511 | - break; |
|
476 | + case ($srcClass == 'Post'): |
|
477 | + if ($navigationPropName == 'Tags') { |
|
478 | + $query = "SELECT t.*, tt.description" |
|
479 | + ." FROM wp_terms AS t" |
|
480 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
481 | + ." ON tt.term_id = t.term_id" |
|
482 | + ." INNER JOIN wp_term_relationships AS tr" |
|
483 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
484 | + ." WHERE tt.taxonomy IN ('post_tag')" |
|
485 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
486 | + ." AND tt.term_id = ".$namedKeyValues['TagID'][0]; |
|
487 | + $stmt = mysql_query($query); |
|
488 | + $result = $this->_serializeTags($stmt); |
|
489 | + } elseif ($navigationPropName == 'Categories') { |
|
490 | + $query = "SELECT t.*, tt.description" |
|
491 | + ." FROM wp_terms AS t" |
|
492 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
493 | + ." ON tt.term_id = t.term_id" |
|
494 | + ." INNER JOIN wp_term_relationships AS tr" |
|
495 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
496 | + ." WHERE tt.taxonomy IN ('category')" |
|
497 | + ." AND tr.object_id IN ($sourceEntityInstance->PostID)" |
|
498 | + ." AND tt.term_id = ".$namedKeyValues['CategoryID'][0]; |
|
499 | + $stmt = mysql_query($query); |
|
500 | + $result = $this->_serializeCategories($stmt); |
|
501 | + } else if ($navigationPropName == 'Comments') { |
|
502 | + $query = "SELECT * FROM `wp_comments`" |
|
503 | + ." WHERE comment_approved = 1" |
|
504 | + ." AND comment_post_ID = $sourceEntityInstance->PostID" |
|
505 | + ." AND comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
506 | + $stmt = mysql_query($query); |
|
507 | + $result = $this->_serializeComments($stmt); |
|
508 | + } else { |
|
509 | + die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
510 | + } |
|
511 | + break; |
|
512 | 512 | |
513 | - case ($srcClass == 'Tag'): |
|
514 | - if ($navigationPropName == 'Posts') { |
|
515 | - $query = "SELECT p . *" |
|
516 | - ." FROM wp_posts AS p" |
|
517 | - ." INNER JOIN wp_term_relationships AS tr" |
|
518 | - ." ON p.ID = tr.object_id" |
|
519 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
520 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
521 | - ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
522 | - ." AND p.post_type = 'post'" |
|
523 | - ." AND p.post_status = 'publish'" |
|
524 | - ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
525 | - $stmt = mysql_query($query); |
|
526 | - $result = $this->_serializePosts($stmt); |
|
527 | - } else { |
|
528 | - die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
529 | - } |
|
530 | - break; |
|
513 | + case ($srcClass == 'Tag'): |
|
514 | + if ($navigationPropName == 'Posts') { |
|
515 | + $query = "SELECT p . *" |
|
516 | + ." FROM wp_posts AS p" |
|
517 | + ." INNER JOIN wp_term_relationships AS tr" |
|
518 | + ." ON p.ID = tr.object_id" |
|
519 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
520 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
521 | + ." WHERE tt.term_id = $sourceEntityInstance->TagID" |
|
522 | + ." AND p.post_type = 'post'" |
|
523 | + ." AND p.post_status = 'publish'" |
|
524 | + ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
525 | + $stmt = mysql_query($query); |
|
526 | + $result = $this->_serializePosts($stmt); |
|
527 | + } else { |
|
528 | + die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
529 | + } |
|
530 | + break; |
|
531 | 531 | |
532 | - case ($srcClass == 'Category'): |
|
533 | - if ($navigationPropName == 'Posts') { |
|
534 | - $query = "SELECT p . *" |
|
535 | - ." FROM wp_posts AS p" |
|
536 | - ." INNER JOIN wp_term_relationships AS tr" |
|
537 | - ." ON p.ID = tr.object_id" |
|
538 | - ." INNER JOIN wp_term_taxonomy AS tt" |
|
539 | - ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
540 | - ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
541 | - ." AND p.post_type = 'post'" |
|
542 | - ." AND p.post_status = 'publish'" |
|
543 | - ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
544 | - $stmt = mysql_query($query); |
|
545 | - $result = $this->_serializePosts($stmt); |
|
546 | - } else { |
|
547 | - die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
548 | - } |
|
549 | - break; |
|
532 | + case ($srcClass == 'Category'): |
|
533 | + if ($navigationPropName == 'Posts') { |
|
534 | + $query = "SELECT p . *" |
|
535 | + ." FROM wp_posts AS p" |
|
536 | + ." INNER JOIN wp_term_relationships AS tr" |
|
537 | + ." ON p.ID = tr.object_id" |
|
538 | + ." INNER JOIN wp_term_taxonomy AS tt" |
|
539 | + ." ON tr.term_taxonomy_id = tt.term_taxonomy_id" |
|
540 | + ." WHERE tt.term_id = $sourceEntityInstance->CategoryID" |
|
541 | + ." AND p.post_type = 'post'" |
|
542 | + ." AND p.post_status = 'publish'" |
|
543 | + ." AND p.ID = ".$namedKeyValues['PostID'][0]; |
|
544 | + $stmt = mysql_query($query); |
|
545 | + $result = $this->_serializePosts($stmt); |
|
546 | + } else { |
|
547 | + die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
548 | + } |
|
549 | + break; |
|
550 | 550 | |
551 | - case ($srcClass == 'Comment'): |
|
552 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
553 | - break; |
|
551 | + case ($srcClass == 'Comment'): |
|
552 | + die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
553 | + break; |
|
554 | 554 | |
555 | - case ($srcClass == 'User'): |
|
556 | - if ($navigationPropName == 'Posts') { |
|
557 | - $query = "SELECT * FROM `wp_posts` WHERE" |
|
558 | - ." wp_posts.post_type = 'post'" |
|
559 | - ." AND wp_posts.post_status = 'publish'" |
|
560 | - ." AND wp_posts.post_author = $sourceEntityInstance->UserID" |
|
561 | - ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
562 | - $stmt = mysql_query($query); |
|
563 | - $result = $this->_serializePosts($stmt); |
|
564 | - } elseif ($navigationPropName == 'Comments') { |
|
565 | - $query = "SELECT * FROM `wp_comments`" |
|
566 | - ." WHERE comment_approved = 1" |
|
567 | - ." AND wp_comments.user_id = $sourceEntityInstance->UserID" |
|
568 | - ." AND wp_comments.comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
569 | - $stmt = mysql_query($query); |
|
570 | - $result = $this->_serializeComments($stmt); |
|
571 | - } else { |
|
572 | - die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
573 | - } |
|
574 | - break; |
|
555 | + case ($srcClass == 'User'): |
|
556 | + if ($navigationPropName == 'Posts') { |
|
557 | + $query = "SELECT * FROM `wp_posts` WHERE" |
|
558 | + ." wp_posts.post_type = 'post'" |
|
559 | + ." AND wp_posts.post_status = 'publish'" |
|
560 | + ." AND wp_posts.post_author = $sourceEntityInstance->UserID" |
|
561 | + ." AND wp_posts.ID = ".$namedKeyValues['PostID'][0]; |
|
562 | + $stmt = mysql_query($query); |
|
563 | + $result = $this->_serializePosts($stmt); |
|
564 | + } elseif ($navigationPropName == 'Comments') { |
|
565 | + $query = "SELECT * FROM `wp_comments`" |
|
566 | + ." WHERE comment_approved = 1" |
|
567 | + ." AND wp_comments.user_id = $sourceEntityInstance->UserID" |
|
568 | + ." AND wp_comments.comment_ID = ".$namedKeyValues['CommentID'][0]; |
|
569 | + $stmt = mysql_query($query); |
|
570 | + $result = $this->_serializeComments($stmt); |
|
571 | + } else { |
|
572 | + die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
573 | + } |
|
574 | + break; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | mysql_free_result($stmt); |
@@ -599,60 +599,60 @@ discard block |
||
599 | 599 | $navigationPropName = $targetProperty->getName(); |
600 | 600 | |
601 | 601 | switch (true) { |
602 | - case ($srcClass == 'Post'): |
|
603 | - if ($navigationPropName == 'User') { |
|
604 | - $query = "SELECT * FROM `wp_users` WHERE ID = $sourceEntityInstance->Author"; |
|
605 | - $stmt = mysql_query($query); |
|
606 | - $stmt = mysql_query($query); |
|
607 | - $data = mysql_fetch_assoc($stmt); |
|
608 | - $result = $this->_serializeUser($data); |
|
609 | - if ( $stmt === false) { |
|
610 | - die(mysql_error()); |
|
611 | - } |
|
602 | + case ($srcClass == 'Post'): |
|
603 | + if ($navigationPropName == 'User') { |
|
604 | + $query = "SELECT * FROM `wp_users` WHERE ID = $sourceEntityInstance->Author"; |
|
605 | + $stmt = mysql_query($query); |
|
606 | + $stmt = mysql_query($query); |
|
607 | + $data = mysql_fetch_assoc($stmt); |
|
608 | + $result = $this->_serializeUser($data); |
|
609 | + if ( $stmt === false) { |
|
610 | + die(mysql_error()); |
|
611 | + } |
|
612 | 612 | |
613 | - if (!mysql_num_rows($stmt)) { |
|
614 | - $result = null; |
|
613 | + if (!mysql_num_rows($stmt)) { |
|
614 | + $result = null; |
|
615 | + } |
|
616 | + } else { |
|
617 | + die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
615 | 618 | } |
616 | - } else { |
|
617 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
618 | - } |
|
619 | - break; |
|
619 | + break; |
|
620 | 620 | |
621 | - case ($srcClass == 'Comment'): |
|
622 | - if ($navigationPropName == 'User') { |
|
623 | - $query = "SELECT * FROM `wp_users` WHERE ID = $sourceEntityInstance->UserID"; |
|
624 | - $stmt = mysql_query($query); |
|
625 | - if ( $stmt === false) { |
|
626 | - die(mysql_error()); |
|
627 | - } |
|
621 | + case ($srcClass == 'Comment'): |
|
622 | + if ($navigationPropName == 'User') { |
|
623 | + $query = "SELECT * FROM `wp_users` WHERE ID = $sourceEntityInstance->UserID"; |
|
624 | + $stmt = mysql_query($query); |
|
625 | + if ( $stmt === false) { |
|
626 | + die(mysql_error()); |
|
627 | + } |
|
628 | 628 | |
629 | - if (!mysql_num_rows($stmt)) { |
|
630 | - $result = null; |
|
631 | - } |
|
629 | + if (!mysql_num_rows($stmt)) { |
|
630 | + $result = null; |
|
631 | + } |
|
632 | 632 | |
633 | - $data = mysql_fetch_assoc($stmt); |
|
634 | - $result = $this->_serializeUser($data); |
|
633 | + $data = mysql_fetch_assoc($stmt); |
|
634 | + $result = $this->_serializeUser($data); |
|
635 | 635 | |
636 | - } elseif ($navigationPropName == 'Post') { |
|
637 | - $query = "SELECT * FROM `wp_posts` WHERE" |
|
638 | - ." wp_posts.post_type = 'post'" |
|
639 | - ." AND wp_posts.post_status = 'publish'" |
|
640 | - ." AND wp_posts.ID = $sourceEntityInstance->PostID"; |
|
641 | - $stmt = mysql_query($query); |
|
642 | - if ( $stmt === false) { |
|
643 | - die(mysql_error()); |
|
644 | - } |
|
636 | + } elseif ($navigationPropName == 'Post') { |
|
637 | + $query = "SELECT * FROM `wp_posts` WHERE" |
|
638 | + ." wp_posts.post_type = 'post'" |
|
639 | + ." AND wp_posts.post_status = 'publish'" |
|
640 | + ." AND wp_posts.ID = $sourceEntityInstance->PostID"; |
|
641 | + $stmt = mysql_query($query); |
|
642 | + if ( $stmt === false) { |
|
643 | + die(mysql_error()); |
|
644 | + } |
|
645 | 645 | |
646 | - if (!mysql_num_rows($stmt)) { |
|
647 | - $result = null; |
|
648 | - } |
|
646 | + if (!mysql_num_rows($stmt)) { |
|
647 | + $result = null; |
|
648 | + } |
|
649 | 649 | |
650 | - $data = mysql_fetch_assoc($stmt); |
|
651 | - $result = $this->_serializePost($data); |
|
652 | - } else { |
|
653 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
654 | - } |
|
655 | - break; |
|
650 | + $data = mysql_fetch_assoc($stmt); |
|
651 | + $result = $this->_serializePost($data); |
|
652 | + } else { |
|
653 | + die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
654 | + } |
|
655 | + break; |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | mysql_free_result($stmt); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function __construct() |
42 | 42 | { |
43 | 43 | $this->_connectionHandle = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true); |
44 | - if ( $this->_connectionHandle ) { |
|
44 | + if ($this->_connectionHandle) { |
|
45 | 45 | } else { |
46 | 46 | die(print_r(mysql_error(), true)); |
47 | 47 | } |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array(Object) |
86 | 86 | */ |
87 | - public function getResourceSet(ResourceSet $resourceSet,$filter=null,$select=null,$orderby=null,$top=null,$skip=null) |
|
87 | + public function getResourceSet(ResourceSet $resourceSet, $filter = null, $select = null, $orderby = null, $top = null, $skip = null) |
|
88 | 88 | { |
89 | - $resourceSetName = $resourceSet->getName(); |
|
89 | + $resourceSetName = $resourceSet->getName(); |
|
90 | 90 | if ($resourceSetName !== 'Posts' |
91 | 91 | && $resourceSetName !== 'Tags' |
92 | 92 | && $resourceSetName !== 'Categories' |
93 | 93 | && $resourceSetName !== 'Comments' |
94 | 94 | && $resourceSetName !== 'Users' |
95 | 95 | ) { |
96 | - die('(WordPressQueryProvider) Unknown resource set ' . $resourceSetName); |
|
96 | + die('(WordPressQueryProvider) Unknown resource set '.$resourceSetName); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getResourceFromResourceSet(ResourceSet $resourceSet, KeyDescriptor $keyDescriptor) |
169 | 169 | { |
170 | - $resourceSetName = $resourceSet->getName(); |
|
170 | + $resourceSetName = $resourceSet->getName(); |
|
171 | 171 | if ($resourceSetName !== 'Posts' |
172 | 172 | && $resourceSetName !== 'Tags' |
173 | 173 | && $resourceSetName !== 'Categories' |
174 | 174 | && $resourceSetName !== 'Comments' |
175 | 175 | && $resourceSetName !== 'Users' |
176 | 176 | ) { |
177 | - die('(WordPressQueryProvider) Unknown resource set ' . $resourceSetName); |
|
177 | + die('(WordPressQueryProvider) Unknown resource set '.$resourceSetName); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | $namedKeyValues = $keyDescriptor->getValidatedNamedValues(); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $sourceEntityInstance, |
287 | 287 | ResourceSet $targetResourceSet, |
288 | 288 | ResourceProperty $targetProperty, |
289 | - $filter=null ,$select=null, $orderby=null, $top=null, $skip=null |
|
289 | + $filter = null, $select = null, $orderby = null, $top = null, $skip = null |
|
290 | 290 | ) { |
291 | 291 | $result = array(); |
292 | 292 | $srcClass = get_class($sourceEntityInstance); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $query .= " AND $filter"; |
308 | 308 | } |
309 | 309 | $stmt = mysql_query($query); |
310 | - if ( $stmt === false) { |
|
310 | + if ($stmt === false) { |
|
311 | 311 | die(mysql_error()); |
312 | 312 | } |
313 | 313 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $query .= " AND $filter"; |
326 | 326 | } |
327 | 327 | $stmt = mysql_query($query); |
328 | - if ( $stmt === false) { |
|
328 | + if ($stmt === false) { |
|
329 | 329 | die(mysql_error()); |
330 | 330 | } |
331 | 331 | |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | $query .= " AND $filter"; |
339 | 339 | } |
340 | 340 | $stmt = mysql_query($query); |
341 | - if ( $stmt === false) { |
|
341 | + if ($stmt === false) { |
|
342 | 342 | die(mysql_error()); |
343 | 343 | } |
344 | 344 | |
345 | 345 | $result = $this->_serializeComments($stmt); |
346 | 346 | } else { |
347 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
347 | + die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
348 | 348 | } |
349 | 349 | break; |
350 | 350 | |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | $query .= " AND $filter"; |
364 | 364 | } |
365 | 365 | $stmt = mysql_query($query); |
366 | - if ( $stmt === false) { |
|
366 | + if ($stmt === false) { |
|
367 | 367 | die(mysql_error()); |
368 | 368 | } |
369 | 369 | |
370 | 370 | $result = $this->_serializePosts($stmt); |
371 | 371 | } else { |
372 | - die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
372 | + die('Tag does not have navigation porperty with name: '.$navigationPropName); |
|
373 | 373 | } |
374 | 374 | break; |
375 | 375 | |
@@ -388,18 +388,18 @@ discard block |
||
388 | 388 | $query .= " AND $filter"; |
389 | 389 | } |
390 | 390 | $stmt = mysql_query($query); |
391 | - if ( $stmt === false) { |
|
391 | + if ($stmt === false) { |
|
392 | 392 | die(mysql_error()); |
393 | 393 | } |
394 | 394 | |
395 | 395 | $result = $this->_serializePosts($stmt); |
396 | 396 | } else { |
397 | - die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
397 | + die('Category does not have navigation porperty with name: '.$navigationPropName); |
|
398 | 398 | } |
399 | 399 | break; |
400 | 400 | |
401 | 401 | case ($srcClass == 'Comment'): |
402 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
402 | + die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
403 | 403 | break; |
404 | 404 | |
405 | 405 | case ($srcClass == 'User'): |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | $query .= " AND $filter"; |
413 | 413 | } |
414 | 414 | $stmt = mysql_query($query); |
415 | - if ( $stmt === false) { |
|
415 | + if ($stmt === false) { |
|
416 | 416 | die(mysql_error()); |
417 | 417 | } |
418 | 418 | |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | $query .= " AND $filter"; |
426 | 426 | } |
427 | 427 | $stmt = mysql_query($query); |
428 | - if ( $stmt === false) { |
|
428 | + if ($stmt === false) { |
|
429 | 429 | die(mysql_error()); |
430 | 430 | } |
431 | 431 | |
432 | 432 | $result = $this->_serializeComments($stmt); |
433 | 433 | } else { |
434 | - die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
434 | + die('User does not have navigation porperty with name: '.$navigationPropName); |
|
435 | 435 | } |
436 | 436 | break; |
437 | 437 | } |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | $stmt = mysql_query($query); |
507 | 507 | $result = $this->_serializeComments($stmt); |
508 | 508 | } else { |
509 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
509 | + die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
510 | 510 | } |
511 | 511 | break; |
512 | 512 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | $stmt = mysql_query($query); |
526 | 526 | $result = $this->_serializePosts($stmt); |
527 | 527 | } else { |
528 | - die('Tag does not have navigation porperty with name: ' . $navigationPropName); |
|
528 | + die('Tag does not have navigation porperty with name: '.$navigationPropName); |
|
529 | 529 | } |
530 | 530 | break; |
531 | 531 | |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | $stmt = mysql_query($query); |
545 | 545 | $result = $this->_serializePosts($stmt); |
546 | 546 | } else { |
547 | - die('Category does not have navigation porperty with name: ' . $navigationPropName); |
|
547 | + die('Category does not have navigation porperty with name: '.$navigationPropName); |
|
548 | 548 | } |
549 | 549 | break; |
550 | 550 | |
551 | 551 | case ($srcClass == 'Comment'): |
552 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
552 | + die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
553 | 553 | break; |
554 | 554 | |
555 | 555 | case ($srcClass == 'User'): |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | $stmt = mysql_query($query); |
570 | 570 | $result = $this->_serializeComments($stmt); |
571 | 571 | } else { |
572 | - die('User does not have navigation porperty with name: ' . $navigationPropName); |
|
572 | + die('User does not have navigation porperty with name: '.$navigationPropName); |
|
573 | 573 | } |
574 | 574 | break; |
575 | 575 | } |
@@ -606,15 +606,15 @@ discard block |
||
606 | 606 | $stmt = mysql_query($query); |
607 | 607 | $data = mysql_fetch_assoc($stmt); |
608 | 608 | $result = $this->_serializeUser($data); |
609 | - if ( $stmt === false) { |
|
609 | + if ($stmt === false) { |
|
610 | 610 | die(mysql_error()); |
611 | 611 | } |
612 | 612 | |
613 | 613 | if (!mysql_num_rows($stmt)) { |
614 | - $result = null; |
|
614 | + $result = null; |
|
615 | 615 | } |
616 | 616 | } else { |
617 | - die('Post does not have navigation porperty with name: ' . $navigationPropName); |
|
617 | + die('Post does not have navigation porperty with name: '.$navigationPropName); |
|
618 | 618 | } |
619 | 619 | break; |
620 | 620 | |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | if ($navigationPropName == 'User') { |
623 | 623 | $query = "SELECT * FROM `wp_users` WHERE ID = $sourceEntityInstance->UserID"; |
624 | 624 | $stmt = mysql_query($query); |
625 | - if ( $stmt === false) { |
|
625 | + if ($stmt === false) { |
|
626 | 626 | die(mysql_error()); |
627 | 627 | } |
628 | 628 | |
629 | 629 | if (!mysql_num_rows($stmt)) { |
630 | - $result = null; |
|
630 | + $result = null; |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | $data = mysql_fetch_assoc($stmt); |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | ." AND wp_posts.post_status = 'publish'" |
640 | 640 | ." AND wp_posts.ID = $sourceEntityInstance->PostID"; |
641 | 641 | $stmt = mysql_query($query); |
642 | - if ( $stmt === false) { |
|
642 | + if ($stmt === false) { |
|
643 | 643 | die(mysql_error()); |
644 | 644 | } |
645 | 645 | |
646 | 646 | if (!mysql_num_rows($stmt)) { |
647 | - $result = null; |
|
647 | + $result = null; |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | $data = mysql_fetch_assoc($stmt); |
651 | 651 | $result = $this->_serializePost($data); |
652 | 652 | } else { |
653 | - die('Comment does not have navigation porperty with name: ' . $navigationPropName); |
|
653 | + die('Comment does not have navigation porperty with name: '.$navigationPropName); |
|
654 | 654 | } |
655 | 655 | break; |
656 | 656 | } |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | private function _serializeComments($result) |
817 | 817 | { |
818 | 818 | $comments = array(); |
819 | - while ( $record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
|
819 | + while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) { |
|
820 | 820 | $comments[] = $this->_serializeComment($record); |
821 | 821 | } |
822 | 822 |
@@ -665,6 +665,7 @@ |
||
665 | 665 | * @param boolean &$needToSerializeResponse On return, this will contain |
666 | 666 | * True if response needs to be |
667 | 667 | * serialized, False otherwise. |
668 | + * @param boolean $needToSerializeResponse |
|
668 | 669 | * |
669 | 670 | * @return string|null The ETag for the entry object if it has eTag properties |
670 | 671 | * NULL otherwise. |
@@ -5,7 +5,6 @@ discard block |
||
5 | 5 | use POData\Common\MimeTypes; |
6 | 6 | use POData\Common\Version; |
7 | 7 | use POData\OperationContext\HTTPRequestMethod; |
8 | -use POData\Providers\Metadata\ResourceTypeKind; |
|
9 | 8 | use POData\Common\ErrorHandler; |
10 | 9 | use POData\Common\Messages; |
11 | 10 | use POData\Common\ODataException; |
@@ -30,11 +29,9 @@ discard block |
||
30 | 29 | use POData\Writers\Json\JsonODataV1Writer; |
31 | 30 | use POData\Writers\Json\JsonODataV2Writer; |
32 | 31 | use POData\Writers\ResponseWriter; |
33 | - |
|
34 | 32 | use POData\Providers\Query\IQueryProvider; |
35 | 33 | use POData\Providers\Metadata\IMetadataProvider; |
36 | 34 | use POData\OperationContext\IOperationContext; |
37 | - |
|
38 | 35 | use POData\Writers\ODataWriterRegistry; |
39 | 36 | |
40 | 37 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | - //TODO: shouldn't we hide this from the interface..if we need it at all. |
|
102 | + //TODO: shouldn't we hide this from the interface..if we need it at all. |
|
103 | 103 | /** |
104 | 104 | * Get the wrapper over developer's IQueryProvider and IMetadataProvider implementation. |
105 | 105 | * |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getProvidersWrapper() |
109 | 109 | { |
110 | - return $this->providersWrapper; |
|
110 | + return $this->providersWrapper; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -228,33 +228,33 @@ discard block |
||
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - /** |
|
232 | - * @return IQueryProvider |
|
233 | - */ |
|
234 | - public abstract function getQueryProvider(); |
|
231 | + /** |
|
232 | + * @return IQueryProvider |
|
233 | + */ |
|
234 | + public abstract function getQueryProvider(); |
|
235 | 235 | |
236 | - /** |
|
237 | - * @return IMetadataProvider |
|
238 | - */ |
|
239 | - public abstract function getMetadataProvider(); |
|
236 | + /** |
|
237 | + * @return IMetadataProvider |
|
238 | + */ |
|
239 | + public abstract function getMetadataProvider(); |
|
240 | 240 | |
241 | - /** |
|
242 | - * @return \POData\Providers\Stream\IStreamProvider |
|
243 | - */ |
|
244 | - public abstract function getStreamProviderX(); |
|
241 | + /** |
|
242 | + * @return \POData\Providers\Stream\IStreamProvider |
|
243 | + */ |
|
244 | + public abstract function getStreamProviderX(); |
|
245 | 245 | |
246 | 246 | |
247 | - /** @var ODataWriterRegistry */ |
|
248 | - private $writerRegistry; |
|
247 | + /** @var ODataWriterRegistry */ |
|
248 | + private $writerRegistry; |
|
249 | 249 | |
250 | - /** |
|
251 | - * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request |
|
252 | - * @return ODataWriterRegistry |
|
253 | - */ |
|
254 | - public function getODataWriterRegistry() |
|
255 | - { |
|
256 | - return $this->writerRegistry; |
|
257 | - } |
|
250 | + /** |
|
251 | + * Returns the ODataWriterRegistry to use when writing the response to a service document or resource request |
|
252 | + * @return ODataWriterRegistry |
|
253 | + */ |
|
254 | + public function getODataWriterRegistry() |
|
255 | + { |
|
256 | + return $this->writerRegistry; |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | 260 | /** |
@@ -300,32 +300,32 @@ discard block |
||
300 | 300 | |
301 | 301 | $this->initialize($this->config); |
302 | 302 | |
303 | - //TODO: this seems like a bad spot to do this |
|
304 | - $this->writerRegistry = new ODataWriterRegistry(); |
|
305 | - $this->registerWriters(); |
|
303 | + //TODO: this seems like a bad spot to do this |
|
304 | + $this->writerRegistry = new ODataWriterRegistry(); |
|
305 | + $this->registerWriters(); |
|
306 | 306 | } |
307 | 307 | |
308 | - //TODO: i don't want this to be public..but it's the only way to test it right now... |
|
309 | - public function registerWriters() |
|
310 | - { |
|
311 | - $registry = $this->getODataWriterRegistry(); |
|
312 | - $serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion(); |
|
313 | - $serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString(); |
|
308 | + //TODO: i don't want this to be public..but it's the only way to test it right now... |
|
309 | + public function registerWriters() |
|
310 | + { |
|
311 | + $registry = $this->getODataWriterRegistry(); |
|
312 | + $serviceVersion = $this->getConfiguration()->getMaxDataServiceVersion(); |
|
313 | + $serviceURI = $this->getHost()->getAbsoluteServiceUri()->getUrlAsString(); |
|
314 | 314 | |
315 | - //We always register the v1 stuff |
|
316 | - $registry->register(new JsonODataV1Writer()); |
|
317 | - $registry->register(new AtomODataWriter($serviceURI)); |
|
315 | + //We always register the v1 stuff |
|
316 | + $registry->register(new JsonODataV1Writer()); |
|
317 | + $registry->register(new AtomODataWriter($serviceURI)); |
|
318 | 318 | |
319 | - if($serviceVersion->compare(Version::v2()) > -1){ |
|
320 | - $registry->register(new JsonODataV2Writer()); |
|
321 | - } |
|
319 | + if($serviceVersion->compare(Version::v2()) > -1){ |
|
320 | + $registry->register(new JsonODataV2Writer()); |
|
321 | + } |
|
322 | 322 | |
323 | - if($serviceVersion->compare(Version::v3()) > -1){ |
|
324 | - $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI)); |
|
325 | - $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI)); |
|
326 | - $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI)); |
|
327 | - } |
|
328 | - } |
|
323 | + if($serviceVersion->compare(Version::v3()) > -1){ |
|
324 | + $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI)); |
|
325 | + $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI)); |
|
326 | + $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI)); |
|
327 | + } |
|
328 | + } |
|
329 | 329 | |
330 | 330 | /** |
331 | 331 | * Serialize the requested resource. |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | |
350 | 350 | $responseContentType = self::getResponseContentType($request, $uriProcessor, $this); |
351 | 351 | |
352 | - if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) { |
|
353 | - //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type |
|
354 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
355 | - } |
|
352 | + if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) { |
|
353 | + //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type |
|
354 | + throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
355 | + } |
|
356 | 356 | |
357 | - $odataModelInstance = null; |
|
357 | + $odataModelInstance = null; |
|
358 | 358 | $hasResponseBody = true; |
359 | 359 | // Execution required at this point if request target to any resource other than |
360 | 360 | // |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | // In the query 'Orders(1245)/$links/Customer', the targeted |
396 | 396 | // Customer might be null |
397 | 397 | if (is_null($result)) { |
398 | - throw ODataException::createResourceNotFoundError( |
|
398 | + throw ODataException::createResourceNotFoundError( |
|
399 | 399 | $request->getIdentifier() |
400 | 400 | ); |
401 | 401 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | if (!is_null($this->_serviceHost->getRequestIfMatch()) |
406 | 406 | && !is_null($this->_serviceHost->getRequestIfNoneMatch()) |
407 | 407 | ) { |
408 | - throw ODataException::createBadRequestError( |
|
408 | + throw ODataException::createBadRequestError( |
|
409 | 409 | Messages::bothIfMatchAndIfNoneMatchHeaderSpecified() |
410 | 410 | ); |
411 | 411 | } |
@@ -441,22 +441,22 @@ discard block |
||
441 | 441 | } |
442 | 442 | } else if ($requestTargetKind == TargetKind::COMPLEX_OBJECT()) { |
443 | 443 | |
444 | - $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject( |
|
444 | + $odataModelInstance = $objectModelSerializer->writeTopLevelComplexObject( |
|
445 | 445 | $result, |
446 | 446 | $request->getProjectedProperty()->getName(), |
447 | - $request->getTargetResourceType() |
|
448 | - ); |
|
447 | + $request->getTargetResourceType() |
|
448 | + ); |
|
449 | 449 | } else if ($requestTargetKind == TargetKind::BAG()) { |
450 | 450 | $odataModelInstance = $objectModelSerializer->writeTopLevelBagObject( |
451 | 451 | $result, |
452 | 452 | $request->getProjectedProperty()->getName(), |
453 | - $request->getTargetResourceType(), |
|
453 | + $request->getTargetResourceType(), |
|
454 | 454 | $odataModelInstance |
455 | 455 | ); |
456 | 456 | } else if ($requestTargetKind == TargetKind::PRIMITIVE()) { |
457 | 457 | $odataModelInstance = $objectModelSerializer->writeTopLevelPrimitive( |
458 | 458 | $result, |
459 | - $request->getProjectedProperty(), |
|
459 | + $request->getProjectedProperty(), |
|
460 | 460 | $odataModelInstance |
461 | 461 | ); |
462 | 462 | } else if ($requestTargetKind == TargetKind::PRIMITIVE_VALUE()) { |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | //Note: Response content type can be null for named stream |
475 | 475 | if ($hasResponseBody && !is_null($responseContentType)) { |
476 | 476 | if ($request->getTargetKind() != TargetKind::MEDIA_RESOURCE() && $responseContentType != MimeTypes::MIME_APPLICATION_OCTETSTREAM) { |
477 | - //append charset for everything except: |
|
478 | - //stream resources as they have their own content type |
|
479 | - //binary properties (they content type will be App Octet for those...is this a good way? we could also decide based upon the projected property |
|
480 | - // |
|
477 | + //append charset for everything except: |
|
478 | + //stream resources as they have their own content type |
|
479 | + //binary properties (they content type will be App Octet for those...is this a good way? we could also decide based upon the projected property |
|
480 | + // |
|
481 | 481 | $responseContentType .= ';charset=utf-8'; |
482 | 482 | } |
483 | 483 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @throws ODataException, HttpHeaderFailure |
506 | 506 | */ |
507 | 507 | public static function getResponseContentType( |
508 | - RequestDescription $request, |
|
508 | + RequestDescription $request, |
|
509 | 509 | UriProcessor $uriProcessor, |
510 | 510 | IService $service |
511 | 511 | ) { |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | // The Accept request-header field specifies media types which are acceptable for the response |
514 | 514 | |
515 | 515 | $host = $service->getHost(); |
516 | - $requestAcceptText = $host->getRequestAccept(); |
|
516 | + $requestAcceptText = $host->getRequestAccept(); |
|
517 | 517 | $requestVersion = $request->getResponseVersion(); |
518 | 518 | |
519 | - //if the $format header is present it overrides the accepts header |
|
520 | - $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT); |
|
521 | - if(!is_null($format)){ |
|
519 | + //if the $format header is present it overrides the accepts header |
|
520 | + $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT); |
|
521 | + if(!is_null($format)){ |
|
522 | 522 | |
523 | 523 | //There's a strange edge case..if application/json is supplied and it's V3 |
524 | 524 | if($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()){ |
@@ -527,127 +527,127 @@ discard block |
||
527 | 527 | $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META; |
528 | 528 | } |
529 | 529 | |
530 | - $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format); |
|
531 | - } |
|
530 | + $requestAcceptText = ServiceHost::translateFormatToMime($requestVersion, $format); |
|
531 | + } |
|
532 | 532 | |
533 | 533 | |
534 | 534 | |
535 | 535 | |
536 | - //The response format can be dictated by the target resource kind. IE a $value will be different then expected |
|
537 | - //getTargetKind doesn't deal with link resources directly and this can change things |
|
538 | - $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind(); |
|
536 | + //The response format can be dictated by the target resource kind. IE a $value will be different then expected |
|
537 | + //getTargetKind doesn't deal with link resources directly and this can change things |
|
538 | + $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind(); |
|
539 | 539 | |
540 | - switch($targetKind){ |
|
541 | - case TargetKind::METADATA(): |
|
542 | - return HttpProcessUtility::selectMimeType( |
|
543 | - $requestAcceptText, |
|
544 | - array(MimeTypes::MIME_APPLICATION_XML) |
|
545 | - ); |
|
540 | + switch($targetKind){ |
|
541 | + case TargetKind::METADATA(): |
|
542 | + return HttpProcessUtility::selectMimeType( |
|
543 | + $requestAcceptText, |
|
544 | + array(MimeTypes::MIME_APPLICATION_XML) |
|
545 | + ); |
|
546 | 546 | |
547 | - case TargetKind::SERVICE_DIRECTORY(): |
|
548 | - return HttpProcessUtility::selectMimeType( |
|
549 | - $requestAcceptText, |
|
550 | - array( |
|
551 | - MimeTypes::MIME_APPLICATION_XML, |
|
552 | - MimeTypes::MIME_APPLICATION_ATOMSERVICE, |
|
553 | - MimeTypes::MIME_APPLICATION_JSON, |
|
547 | + case TargetKind::SERVICE_DIRECTORY(): |
|
548 | + return HttpProcessUtility::selectMimeType( |
|
549 | + $requestAcceptText, |
|
550 | + array( |
|
551 | + MimeTypes::MIME_APPLICATION_XML, |
|
552 | + MimeTypes::MIME_APPLICATION_ATOMSERVICE, |
|
553 | + MimeTypes::MIME_APPLICATION_JSON, |
|
554 | 554 | MimeTypes::MIME_APPLICATION_JSON_FULL_META, |
555 | 555 | MimeTypes::MIME_APPLICATION_JSON_NO_META, |
556 | 556 | MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, |
557 | - MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
557 | + MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
558 | 558 | |
559 | 559 | ) |
560 | - ); |
|
561 | - |
|
562 | - case TargetKind::PRIMITIVE_VALUE(): |
|
563 | - $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN); |
|
564 | - |
|
565 | - if ($request->getIdentifier() != '$count') { |
|
566 | - $projectedProperty = $request->getProjectedProperty(); |
|
567 | - self::assert( |
|
568 | - !is_null($projectedProperty), |
|
569 | - '!is_null($projectedProperty)' |
|
570 | - ); |
|
571 | - $type = $projectedProperty->getInstanceType(); |
|
572 | - self::assert( |
|
573 | - !is_null($type) && $type instanceof IType, |
|
574 | - '!is_null($type) && $type instanceof IType' |
|
575 | - ); |
|
576 | - if ($type instanceof Binary) { |
|
577 | - $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM); |
|
578 | - } |
|
579 | - } |
|
580 | - |
|
581 | - return HttpProcessUtility::selectMimeType( |
|
582 | - $requestAcceptText, |
|
583 | - $supportedResponseMimeTypes |
|
584 | - ); |
|
585 | - |
|
586 | - case TargetKind::PRIMITIVE(): |
|
587 | - case TargetKind::COMPLEX_OBJECT(): |
|
588 | - case TargetKind::BAG(): |
|
589 | - case TargetKind::LINK(): |
|
590 | - return HttpProcessUtility::selectMimeType( |
|
591 | - $requestAcceptText, |
|
592 | - array( |
|
593 | - MimeTypes::MIME_APPLICATION_XML, |
|
594 | - MimeTypes::MIME_TEXTXML, |
|
595 | - MimeTypes::MIME_APPLICATION_JSON, |
|
560 | + ); |
|
561 | + |
|
562 | + case TargetKind::PRIMITIVE_VALUE(): |
|
563 | + $supportedResponseMimeTypes = array(MimeTypes::MIME_TEXTPLAIN); |
|
564 | + |
|
565 | + if ($request->getIdentifier() != '$count') { |
|
566 | + $projectedProperty = $request->getProjectedProperty(); |
|
567 | + self::assert( |
|
568 | + !is_null($projectedProperty), |
|
569 | + '!is_null($projectedProperty)' |
|
570 | + ); |
|
571 | + $type = $projectedProperty->getInstanceType(); |
|
572 | + self::assert( |
|
573 | + !is_null($type) && $type instanceof IType, |
|
574 | + '!is_null($type) && $type instanceof IType' |
|
575 | + ); |
|
576 | + if ($type instanceof Binary) { |
|
577 | + $supportedResponseMimeTypes = array(MimeTypes::MIME_APPLICATION_OCTETSTREAM); |
|
578 | + } |
|
579 | + } |
|
580 | + |
|
581 | + return HttpProcessUtility::selectMimeType( |
|
582 | + $requestAcceptText, |
|
583 | + $supportedResponseMimeTypes |
|
584 | + ); |
|
585 | + |
|
586 | + case TargetKind::PRIMITIVE(): |
|
587 | + case TargetKind::COMPLEX_OBJECT(): |
|
588 | + case TargetKind::BAG(): |
|
589 | + case TargetKind::LINK(): |
|
590 | + return HttpProcessUtility::selectMimeType( |
|
591 | + $requestAcceptText, |
|
592 | + array( |
|
593 | + MimeTypes::MIME_APPLICATION_XML, |
|
594 | + MimeTypes::MIME_TEXTXML, |
|
595 | + MimeTypes::MIME_APPLICATION_JSON, |
|
596 | 596 | MimeTypes::MIME_APPLICATION_JSON_FULL_META, |
597 | 597 | MimeTypes::MIME_APPLICATION_JSON_NO_META, |
598 | 598 | MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, |
599 | - MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
600 | - ) |
|
601 | - ); |
|
602 | - |
|
603 | - case TargetKind::RESOURCE(): |
|
604 | - return HttpProcessUtility::selectMimeType( |
|
605 | - $requestAcceptText, |
|
606 | - array( |
|
607 | - MimeTypes::MIME_APPLICATION_ATOM, |
|
608 | - MimeTypes::MIME_APPLICATION_JSON, |
|
599 | + MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
600 | + ) |
|
601 | + ); |
|
602 | + |
|
603 | + case TargetKind::RESOURCE(): |
|
604 | + return HttpProcessUtility::selectMimeType( |
|
605 | + $requestAcceptText, |
|
606 | + array( |
|
607 | + MimeTypes::MIME_APPLICATION_ATOM, |
|
608 | + MimeTypes::MIME_APPLICATION_JSON, |
|
609 | 609 | MimeTypes::MIME_APPLICATION_JSON_FULL_META, |
610 | 610 | MimeTypes::MIME_APPLICATION_JSON_NO_META, |
611 | 611 | MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META, |
612 | - MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
613 | - ) |
|
614 | - ); |
|
615 | - |
|
616 | - case TargetKind::MEDIA_RESOURCE(): |
|
617 | - if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){ |
|
618 | - throw ODataException::createBadRequestError( |
|
619 | - Messages::badRequestInvalidUriForMediaResource( |
|
620 | - $host->getAbsoluteRequestUri()->getUrlAsString() |
|
621 | - ) |
|
622 | - ); |
|
623 | - } |
|
624 | - |
|
625 | - $uriProcessor->execute(); |
|
626 | - $request->setExecuted(); |
|
627 | - // DSSW::getStreamContentType can throw error in 2 cases |
|
628 | - // 1. If the required stream implementation not found |
|
629 | - // 2. If IDSSP::getStreamContentType returns NULL for MLE |
|
630 | - $responseContentType = $service->getStreamProviderWrapper() |
|
631 | - ->getStreamContentType( |
|
632 | - $request->getTargetResult(), |
|
633 | - $request->getResourceStreamInfo() |
|
634 | - ); |
|
635 | - |
|
636 | - |
|
637 | - // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not |
|
638 | - // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error |
|
639 | - if (!is_null($responseContentType)) { |
|
640 | - $responseContentType = HttpProcessUtility::selectMimeType( |
|
641 | - $requestAcceptText, |
|
642 | - array($responseContentType) |
|
643 | - ); |
|
644 | - } |
|
645 | - |
|
646 | - return $responseContentType; |
|
647 | - } |
|
648 | - |
|
649 | - |
|
650 | - //If we got here, we just don't know what it is... |
|
612 | + MimeTypes::MIME_APPLICATION_JSON_VERBOSE, |
|
613 | + ) |
|
614 | + ); |
|
615 | + |
|
616 | + case TargetKind::MEDIA_RESOURCE(): |
|
617 | + if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){ |
|
618 | + throw ODataException::createBadRequestError( |
|
619 | + Messages::badRequestInvalidUriForMediaResource( |
|
620 | + $host->getAbsoluteRequestUri()->getUrlAsString() |
|
621 | + ) |
|
622 | + ); |
|
623 | + } |
|
624 | + |
|
625 | + $uriProcessor->execute(); |
|
626 | + $request->setExecuted(); |
|
627 | + // DSSW::getStreamContentType can throw error in 2 cases |
|
628 | + // 1. If the required stream implementation not found |
|
629 | + // 2. If IDSSP::getStreamContentType returns NULL for MLE |
|
630 | + $responseContentType = $service->getStreamProviderWrapper() |
|
631 | + ->getStreamContentType( |
|
632 | + $request->getTargetResult(), |
|
633 | + $request->getResourceStreamInfo() |
|
634 | + ); |
|
635 | + |
|
636 | + |
|
637 | + // Note StreamWrapper::getStreamContentType can return NULL if the requested named stream has not |
|
638 | + // yet been uploaded. But for an MLE if IDSSP::getStreamContentType returns NULL then StreamWrapper will throw error |
|
639 | + if (!is_null($responseContentType)) { |
|
640 | + $responseContentType = HttpProcessUtility::selectMimeType( |
|
641 | + $requestAcceptText, |
|
642 | + array($responseContentType) |
|
643 | + ); |
|
644 | + } |
|
645 | + |
|
646 | + return $responseContentType; |
|
647 | + } |
|
648 | + |
|
649 | + |
|
650 | + //If we got here, we just don't know what it is... |
|
651 | 651 | throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
652 | 652 | |
653 | 653 | } |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | if ($this->config->getValidateETagHeader() && !$resourceType->hasETagProperties()) { |
690 | 690 | if (!is_null($ifMatch) || !is_null($ifNoneMatch)) { |
691 | 691 | // No eTag properties but request has eTag headers, bad request |
692 | - throw ODataException::createBadRequestError( |
|
692 | + throw ODataException::createBadRequestError( |
|
693 | 693 | Messages::noETagPropertiesForType() |
694 | 694 | ); |
695 | 695 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | $value = null; |
777 | 777 | try { |
778 | 778 | |
779 | - //TODO #88...also this seems like dupe work |
|
779 | + //TODO #88...also this seems like dupe work |
|
780 | 780 | $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName() ); |
781 | 781 | $value = $reflectionProperty->getValue($entryObject); |
782 | 782 | } catch (\ReflectionException $reflectionException) { |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | $registry->register(new JsonODataV1Writer()); |
317 | 317 | $registry->register(new AtomODataWriter($serviceURI)); |
318 | 318 | |
319 | - if($serviceVersion->compare(Version::v2()) > -1){ |
|
319 | + if ($serviceVersion->compare(Version::v2()) > -1) { |
|
320 | 320 | $registry->register(new JsonODataV2Writer()); |
321 | 321 | } |
322 | 322 | |
323 | - if($serviceVersion->compare(Version::v3()) > -1){ |
|
323 | + if ($serviceVersion->compare(Version::v3()) > -1) { |
|
324 | 324 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::NONE(), $serviceURI)); |
325 | 325 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::MINIMAL(), $serviceURI)); |
326 | 326 | $registry->register(new JsonLightODataWriter(JsonLightMetadataLevel::FULL(), $serviceURI)); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | if (is_null($responseContentType) && $request->getTargetKind() != TargetKind::MEDIA_RESOURCE()) { |
353 | 353 | //the responseContentType can ONLY be null if it's a stream (media resource) and that stream is storing null as the content type |
354 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
354 | + throw new ODataException(Messages::unsupportedMediaType(), 415); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | $odataModelInstance = null; |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | |
519 | 519 | //if the $format header is present it overrides the accepts header |
520 | 520 | $format = $host->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_FORMAT); |
521 | - if(!is_null($format)){ |
|
521 | + if (!is_null($format)) { |
|
522 | 522 | |
523 | 523 | //There's a strange edge case..if application/json is supplied and it's V3 |
524 | - if($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()){ |
|
524 | + if ($format == MimeTypes::MIME_APPLICATION_JSON && $requestVersion == Version::v3()) { |
|
525 | 525 | //then it's actual minimalmetadata |
526 | 526 | //TODO: should this be done with the header text too? |
527 | 527 | $format = MimeTypes::MIME_APPLICATION_JSON_MINIMAL_META; |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | //getTargetKind doesn't deal with link resources directly and this can change things |
538 | 538 | $targetKind = $request->isLinkUri() ? TargetKind::LINK() : $request->getTargetKind(); |
539 | 539 | |
540 | - switch($targetKind){ |
|
540 | + switch ($targetKind) { |
|
541 | 541 | case TargetKind::METADATA(): |
542 | 542 | return HttpProcessUtility::selectMimeType( |
543 | 543 | $requestAcceptText, |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | ); |
615 | 615 | |
616 | 616 | case TargetKind::MEDIA_RESOURCE(): |
617 | - if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()){ |
|
617 | + if (!$request->isNamedStream() && !$request->getTargetResourceType()->isMediaLinkEntry()) { |
|
618 | 618 | throw ODataException::createBadRequestError( |
619 | 619 | Messages::badRequestInvalidUriForMediaResource( |
620 | 620 | $host->getAbsoluteRequestUri()->getUrlAsString() |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | |
649 | 649 | |
650 | 650 | //If we got here, we just don't know what it is... |
651 | - throw new ODataException( Messages::unsupportedMediaType(), 415 ); |
|
651 | + throw new ODataException(Messages::unsupportedMediaType(), 415); |
|
652 | 652 | |
653 | 653 | } |
654 | 654 | |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | * @return string|null The ETag for the entry object if it has eTag properties |
670 | 670 | * NULL otherwise. |
671 | 671 | */ |
672 | - protected function compareETag(&$entryObject, ResourceType &$resourceType, |
|
672 | + protected function compareETag(&$entryObject, ResourceType & $resourceType, |
|
673 | 673 | &$needToSerializeResponse |
674 | 674 | ) { |
675 | 675 | $needToSerializeResponse = true; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | // but that is causing an issue in Linux env where the |
721 | 721 | // firefix browser is unable to parse the ETag in this case. |
722 | 722 | // Need to follow up PHP core devs for this. |
723 | - $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX . $eTag . '"'; |
|
723 | + $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX.$eTag.'"'; |
|
724 | 724 | if (!is_null($ifMatch)) { |
725 | 725 | if (strcmp($eTag, $ifMatch) != 0) { |
726 | 726 | // Requested If-Match value does not match with current |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | // but that is causing an issue in Linux env where the |
744 | 744 | // firefix browser is unable to parse the ETag in this case. |
745 | 745 | // Need to follow up PHP core devs for this. |
746 | - $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX . $eTag . '"'; |
|
746 | + $eTag = ODataConstants::HTTP_WEAK_ETAG_PREFIX.$eTag.'"'; |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | return $eTag; |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * for use in a URI) there are etag properties, NULL if |
763 | 763 | * there is no etag property. |
764 | 764 | */ |
765 | - protected function getETagForEntry(&$entryObject, ResourceType &$resourceType) |
|
765 | + protected function getETagForEntry(&$entryObject, ResourceType & $resourceType) |
|
766 | 766 | { |
767 | 767 | $eTag = null; |
768 | 768 | $comma = null; |
@@ -777,18 +777,18 @@ discard block |
||
777 | 777 | try { |
778 | 778 | |
779 | 779 | //TODO #88...also this seems like dupe work |
780 | - $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName() ); |
|
780 | + $reflectionProperty = new \ReflectionProperty($entryObject, $eTagProperty->getName()); |
|
781 | 781 | $value = $reflectionProperty->getValue($entryObject); |
782 | 782 | } catch (\ReflectionException $reflectionException) { |
783 | 783 | throw ODataException::createInternalServerError( |
784 | - Messages::failedToAccessProperty($eTagProperty->getName(), $resourceType->getName() ) |
|
784 | + Messages::failedToAccessProperty($eTagProperty->getName(), $resourceType->getName()) |
|
785 | 785 | ); |
786 | 786 | } |
787 | 787 | |
788 | 788 | if (is_null($value)) { |
789 | - $eTag = $eTag . $comma. 'null'; |
|
789 | + $eTag = $eTag.$comma.'null'; |
|
790 | 790 | } else { |
791 | - $eTag = $eTag . $comma . $type->convertToOData($value); |
|
791 | + $eTag = $eTag.$comma.$type->convertToOData($value); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | $comma = ','; |