1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: alex |
5
|
|
|
* Date: 15/02/20 |
6
|
|
|
* Time: 6:00 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace AlgoWeb\PODataLaravel\Serialisers; |
10
|
|
|
|
11
|
|
|
use Illuminate\Support\Facades\App; |
12
|
|
|
use POData\Common\InvalidOperationException; |
13
|
|
|
use POData\IService; |
14
|
|
|
use POData\Providers\Metadata\IMetadataProvider; |
15
|
|
|
use POData\UriProcessor\RequestDescription; |
16
|
|
|
use POData\UriProcessor\SegmentStack; |
17
|
|
|
|
18
|
|
|
trait SerialiseDepWrapperTrait |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* The service implementation. |
22
|
|
|
* |
23
|
|
|
* @var IService |
24
|
|
|
*/ |
25
|
|
|
protected $service; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Holds reference to segment stack being processed. |
29
|
|
|
* |
30
|
|
|
* @var SegmentStack |
31
|
|
|
*/ |
32
|
|
|
protected $stack; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Lightweight stack tracking for recursive descent fill. |
36
|
|
|
*/ |
37
|
|
|
protected $lightStack = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Request description instance describes OData request the |
41
|
|
|
* the client has submitted and result of the request. |
42
|
|
|
* |
43
|
|
|
* @var RequestDescription |
44
|
|
|
*/ |
45
|
|
|
protected $request; |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var ModelSerialiser |
50
|
|
|
*/ |
51
|
|
|
protected $modelSerialiser; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var IMetadataProvider |
55
|
|
|
*/ |
56
|
|
|
protected $metaProvider; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Gets the data service instance. |
60
|
|
|
* |
61
|
|
|
* @return IService |
62
|
|
|
*/ |
63
|
|
|
public function getService() |
64
|
|
|
{ |
65
|
|
|
return $this->service; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Gets the segment stack instance. |
70
|
|
|
* |
71
|
|
|
* @return SegmentStack |
72
|
|
|
*/ |
73
|
|
|
public function getStack() |
74
|
|
|
{ |
75
|
|
|
return $this->stack; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Gets reference to the request submitted by client. |
80
|
|
|
* |
81
|
|
|
* @return RequestDescription |
82
|
|
|
* @throws InvalidOperationException |
83
|
|
|
*/ |
84
|
|
|
public function getRequest() |
85
|
|
|
{ |
86
|
|
|
if (null == $this->request) { |
87
|
|
|
throw new InvalidOperationException('Request not yet set'); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
return $this->request; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Sets reference to the request submitted by client. |
95
|
|
|
* |
96
|
|
|
* @param RequestDescription $request |
97
|
|
|
*/ |
98
|
|
|
public function setRequest(RequestDescription $request) |
99
|
|
|
{ |
100
|
|
|
$this->request = $request; |
101
|
|
|
$this->stack->setRequest($request); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return ModelSerialiser |
106
|
|
|
*/ |
107
|
|
|
public function getModelSerialiser() |
108
|
|
|
{ |
109
|
|
|
return $this->modelSerialiser; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return IMetadataProvider |
114
|
|
|
*/ |
115
|
|
|
protected function getMetadata() |
116
|
|
|
{ |
117
|
|
|
if (null == $this->metaProvider) { |
118
|
|
|
$this->metaProvider = App::make('metadata'); |
119
|
|
|
} |
120
|
|
|
return $this->metaProvider; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|