|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PhMap; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class Wrapper |
|
7
|
|
|
* @abstract |
|
8
|
|
|
* @package PhMap |
|
9
|
|
|
*/ |
|
10
|
|
|
abstract class Wrapper implements MapperInterface { |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var MapperInterface |
|
14
|
|
|
*/ |
|
15
|
|
|
private $mapper; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @return Mapper |
|
19
|
|
|
*/ |
|
20
|
18 |
|
protected function getMapper() { |
|
21
|
18 |
|
return $this->mapper; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param MapperInterface $mapper |
|
26
|
|
|
* @return $this |
|
27
|
|
|
*/ |
|
28
|
18 |
|
protected function setMapper(MapperInterface $mapper) { |
|
29
|
18 |
|
$this->mapper = $mapper; |
|
30
|
|
|
|
|
31
|
18 |
|
return $this; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return string |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function getOutputClass() { |
|
38
|
1 |
|
return $this->getMapper() |
|
39
|
1 |
|
->getOutputClass(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param string $class |
|
44
|
|
|
* @return $this |
|
45
|
|
|
*/ |
|
46
|
1 |
|
public function setOutputClass($class) { |
|
47
|
1 |
|
$this->getMapper() |
|
48
|
1 |
|
->setOutputClass($class); |
|
49
|
|
|
|
|
50
|
1 |
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return object |
|
55
|
|
|
*/ |
|
56
|
2 |
|
public function getOutputObject() { |
|
57
|
2 |
|
return $this->getMapper() |
|
58
|
2 |
|
->getOutputObject(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param object $object |
|
63
|
|
|
* @return $this |
|
64
|
|
|
*/ |
|
65
|
1 |
|
public function setOutputObject($object) { |
|
66
|
1 |
|
$this->getMapper() |
|
67
|
1 |
|
->setOutputObject($object); |
|
68
|
|
|
|
|
69
|
1 |
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return integer |
|
74
|
|
|
*/ |
|
75
|
2 |
|
public function getAnnotationAdapterType() { |
|
76
|
2 |
|
return $this->getMapper() |
|
77
|
2 |
|
->getAnnotationAdapterType(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param integer $adapter |
|
82
|
|
|
* @return $this |
|
83
|
|
|
*/ |
|
84
|
3 |
|
public function setAnnotationAdapterType($adapter) { |
|
85
|
3 |
|
$this->getMapper() |
|
86
|
3 |
|
->setAnnotationAdapterType($adapter); |
|
87
|
|
|
|
|
88
|
3 |
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return Transforms |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getTransforms() { |
|
95
|
|
|
return $this->getMapper() |
|
96
|
|
|
->getTransforms(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param Transforms $transforms |
|
101
|
|
|
* @return $this |
|
102
|
|
|
*/ |
|
103
|
1 |
|
public function setTransforms(Transforms $transforms) { |
|
104
|
1 |
|
$this->getMapper() |
|
105
|
1 |
|
->setTransforms($transforms); |
|
106
|
|
|
|
|
107
|
1 |
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return boolean |
|
112
|
|
|
*/ |
|
113
|
|
|
public function hasValidation() { |
|
114
|
|
|
return $this->getMapper() |
|
115
|
|
|
->hasValidation(); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return $this |
|
120
|
|
|
*/ |
|
121
|
4 |
|
public function disableValidation() { |
|
122
|
4 |
|
$this->getMapper() |
|
123
|
4 |
|
->disableValidation(); |
|
124
|
|
|
|
|
125
|
4 |
|
return $this; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @return $this |
|
130
|
|
|
*/ |
|
131
|
|
|
public function enableValidation() { |
|
132
|
|
|
$this->getMapper() |
|
133
|
|
|
->enableValidation(); |
|
134
|
|
|
|
|
135
|
|
|
return $this; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @param array $attributes |
|
140
|
|
|
* @return $this |
|
141
|
|
|
*/ |
|
142
|
1 |
|
public function setSkipAttributes(array $attributes = []) { |
|
143
|
1 |
|
$this->getMapper() |
|
144
|
1 |
|
->setSkipAttributes($attributes); |
|
145
|
|
|
|
|
146
|
1 |
|
return $this; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @return array |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getSkipAttributes() { |
|
153
|
|
|
return $this->getMapper() |
|
154
|
|
|
->getSkipAttributes(); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @return object |
|
159
|
|
|
*/ |
|
160
|
18 |
|
public function map() { |
|
161
|
18 |
|
return $this->getMapper() |
|
162
|
18 |
|
->map(); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* @param string|object $outputClassOrObject |
|
167
|
|
|
* @param integer $adapter |
|
168
|
|
|
* @return $this |
|
169
|
|
|
*/ |
|
170
|
|
|
abstract protected function createMapper( |
|
171
|
|
|
$outputClassOrObject, |
|
172
|
|
|
$adapter = Mapper::MEMORY_ANNOTATION_ADAPTER |
|
173
|
|
|
); |
|
174
|
|
|
|
|
175
|
|
|
} |