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 | private static $c = []; |
||
56 | |||
57 | /** |
||
58 | * Class constructor |
||
59 | * @param AnnotatedInterface $model |
||
60 | * @param string $transformatorClass |
||
61 | */ |
||
62 | 137 | public function __construct(AnnotatedInterface $model, $transformatorClass = TransformatorInterface::class, $meta = null) |
|
75 | |||
76 | /** |
||
77 | * Get transformator class |
||
78 | * @return string |
||
79 | */ |
||
80 | 135 | public function getTransformatorClass() |
|
84 | |||
85 | /** |
||
86 | * Get model instance |
||
87 | * @return AnnotatedInterface |
||
88 | */ |
||
89 | 137 | public function getModel() |
|
93 | |||
94 | /** |
||
95 | * Get Mangan meta data |
||
96 | * @return ManganMeta |
||
97 | */ |
||
98 | 135 | public function getMeta() |
|
102 | |||
103 | /** |
||
104 | * |
||
105 | * @param string $name |
||
106 | * @return mixed |
||
107 | */ |
||
108 | 137 | public function getFor($name) |
|
134 | |||
135 | /** |
||
136 | * Get transformer |
||
137 | * @param string $transformatorClass |
||
138 | * @param DocumentTypeMeta $modelMeta |
||
139 | * @param DocumentPropertyMeta $fieldMeta |
||
140 | * @return object |
||
141 | */ |
||
142 | abstract protected function _getTransformer($transformatorClass, DocumentTypeMeta $modelMeta, DocumentPropertyMeta $fieldMeta); |
||
143 | } |
||
144 |