1 | <?php |
||
19 | class ConstraintUtils |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $entities = []; |
||
26 | |||
27 | /** |
||
28 | * @var \stdClass |
||
29 | */ |
||
30 | private $currentSchema; |
||
31 | |||
32 | /** |
||
33 | * @var \stdClass |
||
34 | */ |
||
35 | private $currentData; |
||
36 | |||
37 | /** |
||
38 | * @var RequestStack |
||
39 | */ |
||
40 | private $requestStack; |
||
41 | |||
42 | /** |
||
43 | * Constructor. |
||
44 | * |
||
45 | * @param DocumentManager $dm DocumentManager |
||
46 | * @param RestUtils $restUtils RestUtils |
||
47 | * @param RequestStack $requestStack RequestStack |
||
48 | * |
||
49 | */ |
||
50 | public function __construct(DocumentManager $dm, RestUtils $restUtils, RequestStack $requestStack) |
||
56 | |||
57 | /** |
||
58 | * Gets a entity from the database as a generic object. All constraints that need the saved data to compare |
||
59 | * values or anything should call this function to get what they need. As this is cached in the instance, |
||
60 | * it will fetched only once even if multiple constraints need that object. |
||
61 | * |
||
62 | * @param string $documentClass document class |
||
63 | * @param string $recordId record id |
||
64 | * |
||
65 | * @throws \Doctrine\ODM\MongoDB\LockException |
||
66 | * @throws \Exception |
||
67 | * |
||
68 | * @return object|null entity |
||
69 | */ |
||
70 | public function getSerializedEntity($documentClass, $recordId) |
||
84 | |||
85 | /** |
||
86 | * Returns the current request entity (as \stdClass) if possible |
||
87 | * |
||
88 | * @return null|object |
||
89 | */ |
||
90 | public function getCurrentEntity() |
||
115 | |||
116 | /** |
||
117 | * gets the current schema. helpful for field schema validators that need access to the whole schema in some way. |
||
118 | * |
||
119 | * @return \stdClass |
||
120 | */ |
||
121 | public function getCurrentSchema() |
||
125 | |||
126 | /** |
||
127 | * gets the current data from the client (the whole object). |
||
128 | * helpful for field schema validators that need access to the whole data in some way. |
||
129 | * |
||
130 | * @return \stdClass |
||
131 | */ |
||
132 | public function getCurrentData() |
||
136 | |||
137 | /** |
||
138 | * called on the first schema validation, before anything else. |
||
139 | * |
||
140 | * @param ConstraintEventSchema $event event |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | public function onSchemaValidation(ConstraintEventSchema $event) |
||
149 | } |
||
150 |