1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace POData\UriProcessor\ResourcePathProcessor\SegmentParser; |
6
|
|
|
|
7
|
|
|
use MyCLabs\Enum\Enum; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @method static TargetKind NOTHING() |
11
|
|
|
* @method static TargetKind SERVICE_DIRECTORY() |
12
|
|
|
* @method static TargetKind RESOURCE() |
13
|
|
|
* @method static TargetKind COMPLEX_OBJECT() |
14
|
|
|
* @method static TargetKind PRIMITIVE() |
15
|
|
|
* @method static TargetKind PRIMITIVE_VALUE() |
16
|
|
|
* @method static TargetKind METADATA() |
17
|
|
|
* @method static TargetKind VOID_SERVICE_OPERATION() |
18
|
|
|
* @method static TargetKind BATCH() |
19
|
|
|
* @method static TargetKind LINK() |
20
|
|
|
* @method static TargetKind MEDIA_RESOURCE() |
21
|
|
|
* @method static TargetKind BAG() |
22
|
|
|
* @method static TargetKind SINGLETON() |
23
|
|
|
*/ |
24
|
|
|
class TargetKind extends Enum |
25
|
|
|
{ |
26
|
|
|
protected const TERMINAL_VALUES = [6 => true, 7 => true, 9 => true, 11 => true, 12 => true]; |
27
|
|
|
protected const DIRECT_PROCESS_VALUES = [2 => true, 7 => true, 9 => true]; |
28
|
|
|
protected const NON_FILTERABLE_VALUES = [3 => true, 4 => true]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Nothing specific is being requested. |
32
|
|
|
* e.g. http://localhost. |
33
|
|
|
*/ |
34
|
|
|
protected const NOTHING = 1; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* A top-level directory of service capabilities. |
38
|
|
|
* e.g. http://localhost/myservice.svc. |
39
|
|
|
*/ |
40
|
|
|
protected const SERVICE_DIRECTORY = 2; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Entity Resource is requested - it can be a collection or a single value. |
44
|
|
|
* e.g. http://localhost/myservice.svc/Customers |
45
|
|
|
* http://localhost/myservice.svc/Customers('ALFKI')/Orders(123). |
46
|
|
|
*/ |
47
|
|
|
protected const RESOURCE = 3; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* A single complex value is requested (eg: an Address). |
51
|
|
|
* e.g. http://localhost/myservice.svc/Address. |
52
|
|
|
*/ |
53
|
|
|
protected const COMPLEX_OBJECT = 4; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* A single value is requested (eg: a Picture property). |
57
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/CustomerName |
58
|
|
|
* http://localhost/myservice.svc/Address/LineNumber. |
59
|
|
|
*/ |
60
|
|
|
protected const PRIMITIVE = 5; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* A single value is requested (eg: the raw stream of a Picture). |
64
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/CustomerName/$value |
65
|
|
|
* http://localhost/myservice.svc/Customers/$count. |
66
|
|
|
*/ |
67
|
|
|
protected const PRIMITIVE_VALUE = 6; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* System metadata. |
71
|
|
|
* e.g. http://localhost/myservice.svc/$metadata. |
72
|
|
|
*/ |
73
|
|
|
protected const METADATA = 7; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* A data-service-defined operation that doesn't return anything. |
77
|
|
|
*/ |
78
|
|
|
protected const VOID_SERVICE_OPERATION = 8; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* The request is a batch request. |
82
|
|
|
* e.g. http://localhost/myservice.svc/$batch. |
83
|
|
|
*/ |
84
|
|
|
protected const BATCH = 9; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* The request is a link operation - bind or unbind or simple get |
88
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/$links/Orders. |
89
|
|
|
*/ |
90
|
|
|
protected const LINK = 10; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* A stream property value is requested. |
94
|
|
|
* e.g. http://localhost/myservice.svc/Albums('trip')/Photos('123')/$value |
95
|
|
|
* e.g. http://localhost/myservice.svc/Albums('trip')/Photos('123')/ThumNail64x64/$value. |
96
|
|
|
*/ |
97
|
|
|
protected const MEDIA_RESOURCE = 11; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* A single bag of primitive or complex values is requested |
101
|
|
|
* e.g. http://localhost/myservice.svc/Customers('ALFKI')/EMails. |
102
|
|
|
*/ |
103
|
|
|
protected const BAG = 12; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* A singleton (parameter-less function wrapper). |
107
|
|
|
*/ |
108
|
|
|
protected const SINGLETON = 13; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Is this segment a terminal segment - nothing else can be added after it? |
112
|
|
|
* |
113
|
|
|
* @return bool |
114
|
|
|
*/ |
115
|
|
|
public function isTerminal(): bool |
116
|
|
|
{ |
117
|
|
|
return array_key_exists($this->getValue(), self::TERMINAL_VALUES); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Can this segment be accessed without necessarily directly touching database? |
122
|
|
|
* |
123
|
|
|
* @return bool |
124
|
|
|
*/ |
125
|
|
|
public function isSpecialPurpose(): bool |
126
|
|
|
{ |
127
|
|
|
return array_key_exists($this->getValue(), self::DIRECT_PROCESS_VALUES); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Is filtering prohibited for this type? |
132
|
|
|
* |
133
|
|
|
* @return bool |
134
|
|
|
*/ |
135
|
|
|
public function isNotFilterable(): bool |
136
|
|
|
{ |
137
|
|
|
return array_key_exists($this->getValue(), self::NON_FILTERABLE_VALUES); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|