|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace garethp\ews\API\ExchangeWebServices; |
|
4
|
|
|
|
|
5
|
|
|
use garethp\ews\API\MiddlewareRequest; |
|
6
|
|
|
use garethp\ews\API\MiddlewareResponse; |
|
7
|
|
|
use garethp\ews\API\Type; |
|
8
|
|
|
use garethp\ews\API\ExchangeWebServices; |
|
9
|
|
|
use garethp\ews\API\Type\FindFolderParentType; |
|
10
|
|
|
use garethp\ews\API\Type\FindItemParentType; |
|
11
|
|
|
|
|
12
|
|
|
class MiddlewareFactory |
|
13
|
|
|
{ |
|
14
|
38 |
|
public function getSoapCall() |
|
15
|
|
|
{ |
|
16
|
1 |
|
return function (MiddlewareRequest $request) { |
|
17
|
38 |
|
$client = $this->getClient(); |
|
|
|
|
|
|
18
|
38 |
|
$response = $client->__call($request->getName(), $request->getArguments()); |
|
19
|
38 |
|
$response = MiddlewareResponse::newResponse($response); |
|
20
|
|
|
|
|
21
|
38 |
|
return $response; |
|
22
|
1 |
|
}; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
38 |
|
public function getTypeToXMLObject() |
|
26
|
|
|
{ |
|
27
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
|
28
|
38 |
|
if ($request->getRequest() instanceof Type) { |
|
29
|
3 |
|
$request->setRequest($request->getRequest()->toXmlObject()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
38 |
|
return $next($request); |
|
33
|
1 |
|
}; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
38 |
|
public function getStripSyncScopeForExchange2007() |
|
37
|
|
|
{ |
|
38
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
|
39
|
38 |
|
$requestObj = $request->getRequest(); |
|
40
|
|
|
|
|
41
|
38 |
|
if ($request->getName() == "SyncFolderItems" |
|
42
|
38 |
|
&& $request->getOptions()['version'] < ExchangeWebServices::VERSION_2010 |
|
43
|
38 |
|
&& isset($requestObj->SyncScope)) { |
|
44
|
|
|
unset($requestObj->SyncScope); |
|
45
|
|
|
$request->setRequest($requestObj); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
38 |
|
return $next($request); |
|
49
|
1 |
|
}; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
38 |
|
public function getProcessResponse() |
|
53
|
|
|
{ |
|
54
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
|
55
|
38 |
|
$response = $next($request); |
|
56
|
|
|
|
|
57
|
38 |
|
$response->setResponse($this->processResponse($response->getResponse())); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
38 |
|
return $response; |
|
60
|
1 |
|
}; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
38 |
|
public function getAddLastRequestToPagedResults() |
|
64
|
|
|
{ |
|
65
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
|
66
|
38 |
|
$response = $next($request); |
|
67
|
|
|
|
|
68
|
38 |
|
$responseObject = $response->getResponse(); |
|
69
|
38 |
|
if (($responseObject instanceof FindItemParentType |
|
70
|
38 |
|
|| $responseObject instanceof FindFolderParentType) |
|
71
|
38 |
|
&& !$responseObject->isIncludesLastItemInRange()) { |
|
72
|
2 |
|
$responseObject->setLastRequest($request->getRequest()); |
|
73
|
2 |
|
$response->setResponse($responseObject); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
38 |
|
return $response; |
|
77
|
1 |
|
}; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.