1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Doctrine\Performance\Mock; |
||
6 | |||
7 | use Doctrine\ORM\EntityManagerInterface; |
||
8 | use Doctrine\ORM\Mapping\ClassMetadata; |
||
9 | use Doctrine\ORM\Proxy\Factory\StaticProxyFactory; |
||
10 | use Doctrine\ORM\Query\ResultSetMapping; |
||
11 | |||
12 | /** |
||
13 | * An entity manager mock that prevents lazy-loading of proxies |
||
14 | */ |
||
15 | class NonProxyLoadingEntityManager implements EntityManagerInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var EntityManagerInterface |
||
19 | */ |
||
20 | private $realEntityManager; |
||
21 | |||
22 | public function __construct(EntityManagerInterface $realEntityManager) |
||
23 | { |
||
24 | $this->realEntityManager = $realEntityManager; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * {@inheritDoc} |
||
29 | */ |
||
30 | public function getProxyFactory() |
||
31 | { |
||
32 | return new StaticProxyFactory($this, $this->realEntityManager->getConfiguration()->buildGhostObjectFactory()); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * {@inheritDoc} |
||
37 | */ |
||
38 | public function getMetadataFactory() : \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory |
||
39 | { |
||
40 | return $this->realEntityManager->getMetadataFactory(); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritDoc} |
||
45 | */ |
||
46 | public function getClassMetadata($className) : ClassMetadata |
||
47 | { |
||
48 | return $this->realEntityManager->getClassMetadata($className); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * {@inheritDoc} |
||
53 | */ |
||
54 | public function getUnitOfWork() |
||
55 | { |
||
56 | return new NonProxyLoadingUnitOfWork(); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritDoc} |
||
61 | */ |
||
62 | public function getCache() : ?\Doctrine\ORM\Cache |
||
63 | { |
||
64 | return $this->realEntityManager->getCache(); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * {@inheritDoc} |
||
69 | */ |
||
70 | public function getConnection() : \Doctrine\DBAL\Connection |
||
71 | { |
||
72 | return $this->realEntityManager->getConnection(); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * {@inheritDoc} |
||
77 | */ |
||
78 | public function getExpressionBuilder() : \Doctrine\ORM\Query\Expr |
||
79 | { |
||
80 | return $this->realEntityManager->getExpressionBuilder(); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * {@inheritDoc} |
||
85 | */ |
||
86 | public function beginTransaction() : void |
||
87 | { |
||
88 | $this->realEntityManager->beginTransaction(); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * {@inheritDoc} |
||
93 | */ |
||
94 | public function transactional(callable $func) |
||
95 | { |
||
96 | return $this->realEntityManager->transactional($func); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * {@inheritDoc} |
||
101 | */ |
||
102 | public function commit() : void |
||
103 | { |
||
104 | $this->realEntityManager->commit(); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * {@inheritDoc} |
||
109 | */ |
||
110 | public function rollback() : void |
||
111 | { |
||
112 | $this->realEntityManager->rollback(); |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * {@inheritDoc} |
||
117 | */ |
||
118 | public function createQuery($dql = '') : \Doctrine\ORM\Query |
||
119 | { |
||
120 | return $this->realEntityManager->createQuery($dql); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * {@inheritDoc} |
||
125 | */ |
||
126 | public function createNamedQuery($name) : \Doctrine\ORM\Query |
||
127 | { |
||
128 | return $this->realEntityManager->createNamedQuery($name); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * {@inheritDoc} |
||
133 | */ |
||
134 | public function createNativeQuery($sql, ResultSetMapping $rsm) : \Doctrine\ORM\NativeQuery |
||
135 | { |
||
136 | return $this->realEntityManager->createNativeQuery($sql, $rsm); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * {@inheritDoc} |
||
141 | */ |
||
142 | public function createNamedNativeQuery($name) : \Doctrine\ORM\NativeQuery |
||
143 | { |
||
144 | return $this->realEntityManager->createNamedNativeQuery($name); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * {@inheritDoc} |
||
149 | */ |
||
150 | public function createQueryBuilder() : \Doctrine\ORM\QueryBuilder |
||
151 | { |
||
152 | return $this->realEntityManager->createQueryBuilder(); |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * {@inheritDoc} |
||
157 | */ |
||
158 | public function getReference($entityName, $id) |
||
159 | { |
||
160 | return $this->realEntityManager->getReference($entityName, $id); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * {@inheritDoc} |
||
165 | */ |
||
166 | public function getPartialReference($entityName, $identifier) |
||
167 | { |
||
168 | return $this->realEntityManager->getPartialReference($entityName, $identifier); |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * {@inheritDoc} |
||
173 | */ |
||
174 | public function close() : void |
||
175 | { |
||
176 | $this->realEntityManager->close(); |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * {@inheritDoc} |
||
181 | */ |
||
182 | public function lock($entity, $lockMode, $lockVersion = null) : void |
||
183 | { |
||
184 | $this->realEntityManager->lock($entity, $lockMode, $lockVersion); |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * {@inheritDoc} |
||
189 | */ |
||
190 | public function getEventManager() : \Doctrine\Common\EventManager |
||
191 | { |
||
192 | return $this->realEntityManager->getEventManager(); |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * {@inheritDoc} |
||
197 | */ |
||
198 | public function getConfiguration() : \Doctrine\ORM\Configuration |
||
199 | { |
||
200 | return $this->realEntityManager->getConfiguration(); |
||
201 | } |
||
202 | |||
203 | /** |
||
204 | * {@inheritDoc} |
||
205 | */ |
||
206 | public function isOpen() : bool |
||
207 | { |
||
208 | return $this->realEntityManager->isOpen(); |
||
209 | } |
||
210 | |||
211 | /** |
||
212 | * {@inheritDoc} |
||
213 | */ |
||
214 | public function getHydrator($hydrationMode) : \Doctrine\ORM\Internal\Hydration\AbstractHydrator |
||
215 | { |
||
216 | return $this->realEntityManager->getHydrator($hydrationMode); |
||
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||
217 | } |
||
218 | |||
219 | /** |
||
220 | * {@inheritDoc} |
||
221 | */ |
||
222 | public function newHydrator($hydrationMode) : \Doctrine\ORM\Internal\Hydration\AbstractHydrator |
||
223 | { |
||
224 | return $this->realEntityManager->newHydrator($hydrationMode); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * {@inheritDoc} |
||
229 | */ |
||
230 | public function getFilters() : \Doctrine\ORM\Query\FilterCollection |
||
231 | { |
||
232 | return $this->realEntityManager->getFilters(); |
||
233 | } |
||
234 | |||
235 | /** |
||
236 | * {@inheritDoc} |
||
237 | */ |
||
238 | public function isFiltersStateClean() : bool |
||
239 | { |
||
240 | return $this->realEntityManager->isFiltersStateClean(); |
||
241 | } |
||
242 | |||
243 | /** |
||
244 | * {@inheritDoc} |
||
245 | */ |
||
246 | public function hasFilters() : bool |
||
247 | { |
||
248 | return $this->realEntityManager->hasFilters(); |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * {@inheritDoc} |
||
253 | */ |
||
254 | public function find($className, $id) |
||
255 | { |
||
256 | return $this->realEntityManager->find($className, $id); |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * {@inheritDoc} |
||
261 | */ |
||
262 | public function persist($object) : void |
||
263 | { |
||
264 | $this->realEntityManager->persist($object); |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * {@inheritDoc} |
||
269 | */ |
||
270 | public function remove($object) : void |
||
271 | { |
||
272 | $this->realEntityManager->remove($object); |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * {@inheritDoc} |
||
277 | */ |
||
278 | public function clear($objectName = null) : void |
||
279 | { |
||
280 | $this->realEntityManager->clear($objectName); |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * {@inheritDoc} |
||
285 | * |
||
286 | * @deprecated |
||
287 | */ |
||
288 | public function merge($object) |
||
289 | { |
||
290 | throw new \BadMethodCallException('@TODO method disabled - will be removed in 3.0 with a release of doctrine/common'); |
||
291 | } |
||
292 | |||
293 | /** |
||
294 | * {@inheritDoc} |
||
295 | * |
||
296 | * @deprecated |
||
297 | */ |
||
298 | public function detach($object) : void |
||
299 | { |
||
300 | throw new \BadMethodCallException('@TODO method disabled - will be removed in 3.0 with a release of doctrine/common'); |
||
301 | } |
||
302 | |||
303 | /** |
||
304 | * {@inheritDoc} |
||
305 | */ |
||
306 | public function refresh($object) : void |
||
307 | { |
||
308 | $this->realEntityManager->refresh($object); |
||
309 | } |
||
310 | |||
311 | /** |
||
312 | * {@inheritDoc} |
||
313 | */ |
||
314 | public function flush() : void |
||
315 | { |
||
316 | $this->realEntityManager->flush(); |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * {@inheritDoc} |
||
321 | */ |
||
322 | public function getRepository($className) : \Doctrine\Common\Persistence\ObjectRepository |
||
323 | { |
||
324 | return $this->realEntityManager->getRepository($className); |
||
325 | } |
||
326 | |||
327 | /** |
||
328 | * {@inheritDoc} |
||
329 | */ |
||
330 | public function initializeObject($obj) : void |
||
331 | { |
||
332 | $this->realEntityManager->initializeObject($obj); |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * {@inheritDoc} |
||
337 | */ |
||
338 | public function contains($object) : bool |
||
339 | { |
||
340 | return $this->realEntityManager->contains($object); |
||
341 | } |
||
342 | |||
343 | /** |
||
344 | * {@inheritDoc} |
||
345 | */ |
||
346 | public function getIdentifierFlattener() : \Doctrine\ORM\Utility\IdentifierFlattener |
||
347 | { |
||
348 | return $this->realEntityManager->getIdentifierFlattener(); |
||
349 | } |
||
350 | } |
||
351 |