Sfoglia il codice sorgente

added constraints check for dbo deserialization

develop
Robin Thoni 8 anni fa
parent
commit
01948a6ecb
2 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 4
    0
      src/Utils/Controller/LuRoute.php
  2. 2
    2
      src/Utils/Dbo/LuDbo.php

+ 4
- 0
src/Utils/Controller/LuRoute.php Vedi File

@@ -184,6 +184,10 @@ class LuRoute {
184 184
             {
185 185
                 throw $e;
186 186
             }
187
+            catch (LuDboConstraintException $e)
188
+            {
189
+                throw $e;
190
+            }
187 191
             catch (\Exception $e)
188 192
             {
189 193
                 throw new LuBusinessException("Unable to parse JSON value for '" . $param->getName() . "'", 400, $e);

+ 2
- 2
src/Utils/Dbo/LuDbo.php Vedi File

@@ -131,8 +131,6 @@ abstract class LuDbo implements \JsonSerializable {
131 131
             $value = null;
132 132
             if (isset($json[$name])) {
133 133
                 $value = static::deserializeValue($json[$name], $type);
134
-                $property->setAccessible(true);
135
-                $property->setValue($dbo, $value);
136 134
             }
137 135
 
138 136
             if ($doc->isNotNull() && is_null($value)) {
@@ -144,6 +142,8 @@ abstract class LuDbo implements \JsonSerializable {
144 142
                     call_user_func_array([$value, $constraint->getMethod()], $constraint->getArguments());
145 143
                 }
146 144
             }
145
+            $property->setAccessible(true);
146
+            $property->setValue($dbo, $value);
147 147
         }
148 148
         return $dbo;
149 149
     }

Loading…
Annulla
Salva