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
|
|
|
protected function getMapper() { |
21
|
|
|
return $this->mapper; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param MapperInterface $mapper |
26
|
|
|
* @return $this |
27
|
|
|
*/ |
28
|
|
|
protected function setMapper(MapperInterface $mapper) { |
29
|
|
|
$this->mapper = $mapper; |
30
|
|
|
|
31
|
|
|
return $this; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return string |
36
|
|
|
*/ |
37
|
|
|
public function getOutputClass() { |
38
|
|
|
return $this->getMapper() |
39
|
|
|
->getOutputClass(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param string $class |
44
|
|
|
* @return $this |
45
|
|
|
*/ |
46
|
|
|
public function setOutputClass($class) { |
47
|
|
|
$this->getMapper() |
48
|
|
|
->setOutputClass($class); |
49
|
|
|
|
50
|
|
|
return $this; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return object |
55
|
|
|
*/ |
56
|
|
|
public function getOutputObject() { |
57
|
|
|
return $this->getMapper() |
58
|
|
|
->getOutputObject(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param object $object |
63
|
|
|
* @return $this |
64
|
|
|
*/ |
65
|
|
|
public function setOutputObject($object) { |
66
|
|
|
$this->getMapper() |
67
|
|
|
->setOutputObject($object); |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return integer |
74
|
|
|
*/ |
75
|
|
|
public function getAnnotationAdapterType() { |
76
|
|
|
return $this->getMapper() |
77
|
|
|
->getAnnotationAdapterType(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param integer $adapter |
82
|
|
|
* @return $this |
83
|
|
|
*/ |
84
|
|
|
public function setAnnotationAdapterType($adapter) { |
85
|
|
|
$this->getMapper() |
86
|
|
|
->setAnnotationAdapterType($adapter); |
87
|
|
|
|
88
|
|
|
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
|
|
|
public function setTransforms(Transforms $transforms) { |
104
|
|
|
$this->getMapper() |
105
|
|
|
->setTransforms($transforms); |
106
|
|
|
|
107
|
|
|
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
|
|
|
public function disableValidation() { |
122
|
|
|
$this->getMapper() |
123
|
|
|
->disableValidation(); |
124
|
|
|
|
125
|
|
|
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
|
|
|
public function setSkipAttributes(array $attributes = []) { |
143
|
|
|
$this->getMapper() |
144
|
|
|
->setSkipAttributes($attributes); |
145
|
|
|
|
146
|
|
|
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
|
|
|
public function map() { |
161
|
|
|
return $this->getMapper() |
162
|
|
|
->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
|
|
|
} |