1 | <?php |
||
20 | class ConstraintUtils |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | private $entities = []; |
||
27 | |||
28 | /** |
||
29 | * @var \stdClass |
||
30 | */ |
||
31 | private $currentSchema; |
||
32 | |||
33 | /** |
||
34 | * @var \stdClass |
||
35 | */ |
||
36 | private $currentData; |
||
37 | |||
38 | /** |
||
39 | * @var RequestStack |
||
40 | */ |
||
41 | private $requestStack; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param DocumentManager $dm DocumentManager |
||
47 | * @param RestUtils $restUtils RestUtils |
||
48 | * @param RequestStack $requestStack RequestStack |
||
49 | * |
||
50 | */ |
||
51 | public function __construct(DocumentManager $dm, RestUtils $restUtils, RequestStack $requestStack) |
||
52 | { |
||
53 | $this->dm = $dm; |
||
54 | $this->restUtils = $restUtils; |
||
55 | $this->requestStack = $requestStack; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Gets a entity from the database as a generic object. All constraints that need the saved data to compare |
||
60 | * values or anything should call this function to get what they need. As this is cached in the instance, |
||
61 | * it will fetched only once even if multiple constraints need that object. |
||
62 | * |
||
63 | * @param string $documentClass document class |
||
64 | * @param string $recordId record id |
||
65 | * |
||
66 | * @throws \Doctrine\ODM\MongoDB\LockException |
||
67 | * @throws \Exception |
||
68 | * |
||
69 | * @return object|null entity |
||
70 | */ |
||
71 | public function getSerializedEntity($documentClass, $recordId) |
||
85 | |||
86 | /** |
||
87 | * Returns the current request entity (as \stdClass) if possible |
||
88 | * |
||
89 | * @return null|object |
||
90 | */ |
||
91 | public function getCurrentEntity() |
||
116 | |||
117 | /** |
||
118 | * Returns the request method of the current request |
||
119 | * |
||
120 | * @return null|string the request method |
||
121 | */ |
||
122 | public function getCurrentRequestMethod() |
||
129 | |||
130 | /** |
||
131 | * Returns the current request content |
||
132 | * |
||
133 | * @return bool|null|resource|string the content |
||
|
|||
134 | */ |
||
135 | public function getCurrentRequestContent() |
||
142 | |||
143 | /** |
||
144 | * gets the current schema. helpful for field schema validators that need access to the whole schema in some way. |
||
145 | * |
||
146 | * @return \stdClass |
||
147 | */ |
||
148 | public function getCurrentSchema() |
||
152 | |||
153 | /** |
||
154 | * gets the current data from the client (the whole object). |
||
155 | * helpful for field schema validators that need access to the whole data in some way. |
||
156 | * |
||
157 | * @return \stdClass |
||
158 | */ |
||
159 | public function getCurrentData() |
||
163 | |||
164 | /** |
||
165 | * own function to get standard path from a JsonPointer object |
||
166 | * |
||
167 | * @param JsonPointer|null $pointer pointer |
||
168 | * |
||
169 | * @return string path as string |
||
170 | */ |
||
171 | public function getNormalizedPathFromPointer(JsonPointer $pointer = null) |
||
181 | |||
182 | /** |
||
183 | * called on the first schema validation, before anything else. |
||
184 | * |
||
185 | * @param ConstraintEventSchema $event event |
||
186 | * |
||
187 | * @return void |
||
188 | */ |
||
189 | public function onSchemaValidation(ConstraintEventSchema $event) |
||
194 | } |
||
195 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.