1 | <?php |
||
29 | abstract class Transformator |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * Metadata for document |
||
34 | * @var ManganMeta |
||
35 | */ |
||
36 | private $meta = null; |
||
37 | |||
38 | /** |
||
39 | * Hash map of sanitizers |
||
40 | * @var object[] |
||
41 | */ |
||
42 | private $transformators = []; |
||
43 | |||
44 | /** |
||
45 | * Model |
||
46 | * @var object |
||
47 | */ |
||
48 | private $model = null; |
||
49 | |||
50 | /** |
||
51 | * Transormator class name |
||
52 | * @var string |
||
53 | */ |
||
54 | private $transformatorClass = TransformatorInterface::class; |
||
55 | |||
56 | /** |
||
57 | * Class constructor |
||
58 | * @param AnnotatedInterface $model |
||
59 | * @param string $transformatorClass |
||
60 | */ |
||
61 | 125 | public function __construct(AnnotatedInterface $model, $transformatorClass = TransformatorInterface::class) |
|
67 | |||
68 | /** |
||
69 | * Get transformator class |
||
70 | * @return string |
||
71 | */ |
||
72 | 123 | public function getTransformatorClass() |
|
76 | |||
77 | /** |
||
78 | * Get model instance |
||
79 | * @return AnnotatedInterface |
||
80 | */ |
||
81 | 125 | public function getModel() |
|
85 | |||
86 | /** |
||
87 | * Get Mangan meta data |
||
88 | * @return ManganMeta |
||
89 | */ |
||
90 | 123 | public function getMeta() |
|
94 | |||
95 | /** |
||
96 | * |
||
97 | * @param string $name |
||
98 | * @return mixed |
||
99 | */ |
||
100 | 125 | public function getFor($name) |
|
118 | |||
119 | public function __get($name) |
||
123 | |||
124 | public function __set($name, $value) |
||
128 | |||
129 | /** |
||
130 | * Get transformer |
||
131 | * @param string $transformatorClass |
||
132 | * @param DocumentTypeMeta $modelMeta |
||
133 | * @param DocumentPropertyMeta $fieldMeta |
||
134 | * @return object |
||
135 | */ |
||
136 | abstract protected function _getTransformer($transformatorClass, DocumentTypeMeta $modelMeta, DocumentPropertyMeta $fieldMeta); |
||
137 | } |
||
138 |