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
|
30 |
|
public function getSoapCall() |
15
|
|
|
{ |
16
|
1 |
|
return function (MiddlewareRequest $request) { |
17
|
30 |
|
$client = $this->getClient(); |
|
|
|
|
18
|
30 |
|
$response = $client->__call($request->getName(), $request->getArguments()); |
19
|
30 |
|
$response = MiddlewareResponse::newResponse($response); |
20
|
|
|
|
21
|
30 |
|
return $response; |
22
|
1 |
|
}; |
23
|
|
|
} |
24
|
|
|
|
25
|
30 |
|
public function getTypeToXMLObject() |
26
|
|
|
{ |
27
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
28
|
30 |
|
if ($request->getRequest() instanceof Type) { |
29
|
2 |
|
$request->setRequest($request->getRequest()->toXmlObject()); |
30
|
|
|
} |
31
|
|
|
|
32
|
30 |
|
return $next($request); |
33
|
1 |
|
}; |
34
|
|
|
} |
35
|
|
|
|
36
|
30 |
|
public function getStripSyncScopeForExchange2007() |
37
|
|
|
{ |
38
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
39
|
30 |
|
$requestObj = $request->getRequest(); |
40
|
|
|
|
41
|
30 |
|
if ($request->getName() == "SyncFolderItems" |
42
|
30 |
|
&& $request->getOptions()['version'] < ExchangeWebServices::VERSION_2010 |
43
|
30 |
|
&& isset($requestObj->SyncScope)) { |
44
|
|
|
unset($requestObj->SyncScope); |
45
|
|
|
$request->setRequest($requestObj); |
46
|
|
|
} |
47
|
|
|
|
48
|
30 |
|
return $next($request); |
49
|
1 |
|
}; |
50
|
|
|
} |
51
|
|
|
|
52
|
30 |
|
public function getProcessResponse() |
53
|
|
|
{ |
54
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
55
|
30 |
|
$response = $next($request); |
56
|
|
|
|
57
|
30 |
|
$response->setResponse($this->processResponse($response->getResponse())); |
|
|
|
|
58
|
|
|
|
59
|
30 |
|
return $response; |
60
|
1 |
|
}; |
61
|
|
|
} |
62
|
|
|
|
63
|
30 |
|
public function getAddLastRequestToPagedResults() |
64
|
|
|
{ |
65
|
1 |
|
return function (MiddlewareRequest $request, callable $next) { |
66
|
30 |
|
$response = $next($request); |
67
|
|
|
|
68
|
30 |
|
$responseObject = $response->getResponse(); |
69
|
30 |
|
if (($responseObject instanceof FindItemParentType |
70
|
30 |
|
|| $responseObject instanceof FindFolderParentType) |
71
|
30 |
|
&& !$responseObject->isIncludesLastItemInRange()) { |
72
|
2 |
|
$responseObject->setLastRequest($request->getRequest()); |
73
|
2 |
|
$response->setResponse($responseObject); |
74
|
|
|
} |
75
|
|
|
|
76
|
30 |
|
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.