1 | <?php |
||
27 | class UnderscoreIdFieldDecorator implements ModelDecoratorInterface |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * Key used instead of `_id` |
||
32 | */ |
||
33 | const Key = '_mongo_id_'; |
||
34 | |||
35 | /** |
||
36 | * This will be called when getting value. |
||
37 | * This should return end user value. |
||
38 | * @param AnnotatedInterface $model Document model which will be decorated |
||
39 | * @param mixed $dbValues |
||
40 | * @param string $transformatorClass Transformator class used |
||
41 | * @return bool Return true if value should be assigned to model |
||
42 | */ |
||
43 | 24 | public function read($model, &$dbValues, $transformatorClass = TransformatorInterface::class) |
|
55 | |||
56 | /** |
||
57 | * This will be called when setting value. |
||
58 | * This should return db acceptable value |
||
59 | * @param AnnotatedInterface $model Model which is about to be decorated |
||
60 | * @param mixed[] $dbValues Whole model values from database. This is associative array with keys same as model properties (use $name param to access value). This is passed by reference. |
||
61 | * @param string $transformatorClass Transformator class used |
||
62 | * @return bool Return true to store value to database |
||
63 | */ |
||
64 | 53 | public function write($model, &$dbValues, $transformatorClass = TransformatorInterface::class) |
|
73 | |||
74 | } |
||
75 |