1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \AppserverIo\Appserver\PersistenceContainer\Doctrine\DoctrineEntityManagerProxy |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io/appserver |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Appserver\PersistenceContainer\Doctrine; |
22
|
|
|
|
23
|
|
|
use Doctrine\ORM\Query\ResultSetMapping; |
24
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
25
|
|
|
use AppserverIo\RemoteMethodInvocation\SessionInterface; |
26
|
|
|
use AppserverIo\RemoteMethodInvocation\RemoteMethodCall; |
27
|
|
|
use AppserverIo\RemoteMethodInvocation\RemoteMethodInterface; |
28
|
|
|
use AppserverIo\RemoteMethodInvocation\RemoteObjectInterface; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Decorator for the Doctrine entity manager instance. |
32
|
|
|
* |
33
|
|
|
* @author Tim Wagner <[email protected]> |
34
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
35
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
36
|
|
|
* @link https://github.com/appserver-io/appserver |
37
|
|
|
* @link http://www.appserver.io |
38
|
|
|
*/ |
39
|
|
|
class DoctrineEntityManagerProxy implements RemoteObjectInterface, EntityManagerInterface |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Holds the ContextSession for this proxy. |
44
|
|
|
* |
45
|
|
|
* @var \AppserverIo\RemoteMethodInvocation\SessionInterface |
46
|
|
|
*/ |
47
|
|
|
protected $session = null; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The class name to proxy. |
51
|
|
|
* |
52
|
|
|
* @var string $className |
53
|
|
|
*/ |
54
|
|
|
protected $className = null; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Initializes the proxy with the class name to proxy. |
58
|
|
|
* |
59
|
|
|
* @param mixed $className The name of the class to create the proxy for |
60
|
|
|
*/ |
61
|
|
|
public function __construct($className = 'AppserverIo\Appserver\Core\InitialContext') |
62
|
|
|
{ |
63
|
|
|
$this->className = $className; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* The name of the original object. |
68
|
|
|
* |
69
|
|
|
* @return string The name of the original object |
70
|
|
|
* @see \AppserverIo\RemoteMethodInvocation\RemoteObjectInterface::__getClassName() |
71
|
|
|
*/ |
72
|
|
|
public function __getClassName() |
73
|
|
|
{ |
74
|
|
|
return $this->className; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Sets the session with the connection instance. |
79
|
|
|
* |
80
|
|
|
* @param \AppserverIo\RemoteMethodInvocation\SessionInterface $session The session instance to use |
81
|
|
|
* |
82
|
|
|
* @return \AppserverIo\RemoteMethodInvocation\RemoteObjectInterface The instance itself |
83
|
|
|
*/ |
84
|
|
|
public function __setSession(SessionInterface $session) |
85
|
|
|
{ |
86
|
|
|
$this->session = $session; |
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Returns the session instance. |
92
|
|
|
* |
93
|
|
|
* @return \AppserverIo\RemoteMethodInvocation\SessionInterface The session instance |
94
|
|
|
* @see \AppserverIo\RemoteMethodInvocation\RemoteObjectInterface::__getSession() |
95
|
|
|
*/ |
96
|
|
|
public function __getSession() |
97
|
|
|
{ |
98
|
|
|
return $this->session; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Invokes the remote execution of the passed remote method. |
103
|
|
|
* |
104
|
|
|
* @param string $method The remote method to call |
105
|
|
|
* @param array $params The parameters for the method call |
106
|
|
|
* |
107
|
|
|
* @return mixed The result of the remote method call |
108
|
|
|
*/ |
109
|
|
|
public function __call($method, $params) |
110
|
|
|
{ |
111
|
|
|
$methodCall = new RemoteMethodCall($this->__getClassName(), $method, $this->__getSession()->getSessionId()); |
112
|
|
|
foreach ($params as $key => $value) { |
113
|
|
|
$methodCall->addParameter($key, $value); |
114
|
|
|
} |
115
|
|
|
return $this->__invoke($methodCall, $this->__getSession()); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Invokes the remote execution of the passed remote method. |
120
|
|
|
* |
121
|
|
|
* @param \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface $methodCall The remote method call instance |
122
|
|
|
* @param \AppserverIo\RemoteMethodInvocation\SessionInterface $session The session with the connection instance to use |
123
|
|
|
* |
124
|
|
|
* @return mixed The result of the remote method call |
125
|
|
|
*/ |
126
|
|
|
public function __invoke(RemoteMethodInterface $methodCall, SessionInterface $session) |
127
|
|
|
{ |
128
|
|
|
return $this->__setSession($session)->__getSession()->send($methodCall); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Factory method to create a new instance of the requested proxy implementation. |
133
|
|
|
* |
134
|
|
|
* @param string $className The name of the class to create the proxy for |
135
|
|
|
* |
136
|
|
|
* @return \AppserverIo\RemoteMethodInvocation\RemoteObjectInterface The proxy instance |
137
|
|
|
*/ |
138
|
|
|
public static function __create($className) |
139
|
|
|
{ |
140
|
|
|
return new DoctrineEntityManagerProxy($className); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Gets the database connection object used by the EntityManager. |
145
|
|
|
* |
146
|
|
|
* @return \Doctrine\DBAL\Connection |
147
|
|
|
*/ |
148
|
|
|
public function getConnection() |
149
|
|
|
{ |
150
|
|
|
return $this->__call('getConnection', array()); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Gets an ExpressionBuilder used for object-oriented construction of query expressions. |
155
|
|
|
* |
156
|
|
|
* Example: |
157
|
|
|
* |
158
|
|
|
* <code> |
159
|
|
|
* $qb = $em->createQueryBuilder(); |
160
|
|
|
* $expr = $em->getExpressionBuilder(); |
161
|
|
|
* $qb->select('u')->from('User', 'u') |
162
|
|
|
* ->where($expr->orX($expr->eq('u.id', 1), $expr->eq('u.id', 2))); |
163
|
|
|
* </code> |
164
|
|
|
* |
165
|
|
|
* @return \Doctrine\ORM\Query\Expr |
166
|
|
|
*/ |
167
|
|
|
public function getExpressionBuilder() |
168
|
|
|
{ |
169
|
|
|
return $this->__call('getExpressionBuilder', array()); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Starts a transaction on the underlying database connection. |
174
|
|
|
* |
175
|
|
|
* @return void |
176
|
|
|
*/ |
177
|
|
|
public function beginTransaction() |
178
|
|
|
{ |
179
|
|
|
return $this->__call('beginTransaction', array()); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Executes a function in a transaction. |
184
|
|
|
* |
185
|
|
|
* The function gets passed this EntityManager instance as an (optional) parameter. |
186
|
|
|
* |
187
|
|
|
* {@link flush} is invoked prior to transaction commit. |
188
|
|
|
* |
189
|
|
|
* If an exception occurs during execution of the function or flushing or transaction commit, |
190
|
|
|
* the transaction is rolled back, the EntityManager closed and the exception re-thrown. |
191
|
|
|
* |
192
|
|
|
* @param callable $func The function to execute transactionally. |
193
|
|
|
* |
194
|
|
|
* @return mixed The non-empty value returned from the closure or true instead. |
195
|
|
|
*/ |
196
|
|
|
public function transactional($func) |
197
|
|
|
{ |
198
|
|
|
return $this->__call('transactional', array($func)); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Commits a transaction on the underlying database connection. |
203
|
|
|
* |
204
|
|
|
* @return void |
205
|
|
|
*/ |
206
|
|
|
public function commit() |
207
|
|
|
{ |
208
|
|
|
return $this->__call('commit', array()); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Performs a rollback on the underlying database connection. |
213
|
|
|
* |
214
|
|
|
* @return void |
215
|
|
|
*/ |
216
|
|
|
public function rollback() |
217
|
|
|
{ |
218
|
|
|
return $this->__call('rollback', array()); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Creates a new Query object. |
223
|
|
|
* |
224
|
|
|
* @param string $dql The DQL string. |
225
|
|
|
* |
226
|
|
|
* @return \Doctrine\ORM\Query |
227
|
|
|
*/ |
228
|
|
|
public function createQuery($dql = '') |
229
|
|
|
{ |
230
|
|
|
return $this->__call('createQuery', array($dql)); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Creates a Query from a named query. |
235
|
|
|
* |
236
|
|
|
* @param string $name The query name |
237
|
|
|
* |
238
|
|
|
* @return \Doctrine\ORM\Query |
239
|
|
|
*/ |
240
|
|
|
public function createNamedQuery($name) |
241
|
|
|
{ |
242
|
|
|
return $this->__call('createNamedQuery', array($name)); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Creates a native SQL query. |
247
|
|
|
* |
248
|
|
|
* @param string $sql The SQL command |
249
|
|
|
* @param ResultSetMapping $rsm The ResultSetMapping to use |
250
|
|
|
* |
251
|
|
|
* @return \Doctrine\ORM\NativeQuery The query instance |
252
|
|
|
*/ |
253
|
|
|
public function createNativeQuery($sql, ResultSetMapping $rsm) |
254
|
|
|
{ |
255
|
|
|
return $this->__call('createNativeQuery', array($sql, $rsm)); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Creates a NativeQuery from a named native query. |
260
|
|
|
* |
261
|
|
|
* @param string $name The query name |
262
|
|
|
* |
263
|
|
|
* @return \Doctrine\ORM\NativeQuery The query instance |
264
|
|
|
*/ |
265
|
|
|
public function createNamedNativeQuery($name) |
266
|
|
|
{ |
267
|
|
|
return $this->__call('createNamedNativeQuery', array($name)); |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Create a QueryBuilder instance |
272
|
|
|
* |
273
|
|
|
* @return \Doctrine\ORM\QueryBuilder The query builder instance |
274
|
|
|
*/ |
275
|
|
|
public function createQueryBuilder() |
276
|
|
|
{ |
277
|
|
|
return $this->__call('createQueryBuilder', array()); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* Gets a reference to the entity identified by the given type and identifier |
282
|
|
|
* without actually loading it, if the entity is not yet loaded. |
283
|
|
|
* |
284
|
|
|
* @param string $entityName The name of the entity type. |
285
|
|
|
* @param mixed $id The entity identifier. |
286
|
|
|
* |
287
|
|
|
* @return object The entity reference. |
288
|
|
|
* |
289
|
|
|
* @throws \Doctrine\ORM\ORMException |
290
|
|
|
*/ |
291
|
|
|
public function getReference($entityName, $id) |
292
|
|
|
{ |
293
|
|
|
return $this->__call('getReference', array($entityName, $id)); |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Gets a partial reference to the entity identified by the given type and identifier |
298
|
|
|
* without actually loading it, if the entity is not yet loaded. |
299
|
|
|
* |
300
|
|
|
* The returned reference may be a partial object if the entity is not yet loaded/managed. |
301
|
|
|
* If it is a partial object it will not initialize the rest of the entity state on access. |
302
|
|
|
* Thus you can only ever safely access the identifier of an entity obtained through |
303
|
|
|
* this method. |
304
|
|
|
* |
305
|
|
|
* The use-cases for partial references involve maintaining bidirectional associations |
306
|
|
|
* without loading one side of the association or to update an entity without loading it. |
307
|
|
|
* Note, however, that in the latter case the original (persistent) entity data will |
308
|
|
|
* never be visible to the application (especially not event listeners) as it will |
309
|
|
|
* never be loaded in the first place. |
310
|
|
|
* |
311
|
|
|
* @param string $entityName The name of the entity type. |
312
|
|
|
* @param mixed $identifier The entity identifier. |
313
|
|
|
* |
314
|
|
|
* @return object The (partial) entity reference. |
315
|
|
|
*/ |
316
|
|
|
public function getPartialReference($entityName, $identifier) |
317
|
|
|
{ |
318
|
|
|
return $this->__call('getPartialReference', array($entityName, $identifier)); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* Closes the EntityManager. All entities that are currently managed |
323
|
|
|
* by this EntityManager become detached. The EntityManager may no longer |
324
|
|
|
* be used after it is closed. |
325
|
|
|
* |
326
|
|
|
* @return void |
327
|
|
|
*/ |
328
|
|
|
public function close() |
329
|
|
|
{ |
330
|
|
|
return $this->__call('close', array()); |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Creates a copy of the given entity. Can create a shallow or a deep copy. |
335
|
|
|
* |
336
|
|
|
* @param object $entity The entity to copy. |
337
|
|
|
* @param boolean $deep FALSE for a shallow copy, TRUE for a deep copy. |
338
|
|
|
* |
339
|
|
|
* @return object The new entity. |
340
|
|
|
* |
341
|
|
|
* @throws \BadMethodCallException |
342
|
|
|
*/ |
343
|
|
|
public function copy($entity, $deep = false) |
344
|
|
|
{ |
345
|
|
|
return $this->__call('copy', array($entity, $deep)); |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
/** |
349
|
|
|
* Acquire a lock on the given entity. |
350
|
|
|
* |
351
|
|
|
* @param object $entity The entity to be locked |
352
|
|
|
* @param integer $lockMode The lock mode |
353
|
|
|
* @param integer|null $lockVersion The lock version |
354
|
|
|
* |
355
|
|
|
* @return void |
356
|
|
|
* |
357
|
|
|
* @throws \Doctrine\ORM\OptimisticLockException |
358
|
|
|
* @throws \Doctrine\ORM\PessimisticLockException |
359
|
|
|
*/ |
360
|
|
|
public function lock($entity, $lockMode, $lockVersion = null) |
361
|
|
|
{ |
362
|
|
|
return $this->__call('lock', array($lockMode, $lockVersion)); |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* Finds an Entity by its identifier. |
367
|
|
|
* |
368
|
|
|
* @param string $entityName The class name of the entity to find. |
369
|
|
|
* @param mixed $id The identity of the entity to find. |
370
|
|
|
* @param integer|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants |
371
|
|
|
* or NULL if no specific lock mode should be used |
372
|
|
|
* during the search. |
373
|
|
|
* @param integer|null $lockVersion The version of the entity to find when using |
374
|
|
|
* optimistic locking. |
375
|
|
|
* |
376
|
|
|
* @return object|null The entity instance or NULL if the entity can not be found. |
377
|
|
|
* |
378
|
|
|
* @throws \Doctrine\ORM\OptimisticLockException |
379
|
|
|
* @throws \Doctrine\ORM\ORMInvalidArgumentException |
380
|
|
|
* @throws \Doctrine\ORM\TransactionRequiredException |
381
|
|
|
* @throws \Doctrine\ORM\ORMException |
382
|
|
|
*/ |
383
|
|
|
public function find($entityName, $id, $lockMode = null, $lockVersion = null) |
384
|
|
|
{ |
385
|
|
|
return $this->__call('find', array($entityName, $id, $lockMode, $lockVersion)); |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
/** |
389
|
|
|
* Flushes all changes to objects that have been queued up to now to the database. |
390
|
|
|
* This effectively synchronizes the in-memory state of managed objects with the |
391
|
|
|
* database. |
392
|
|
|
* |
393
|
|
|
* If an entity is explicitly passed to this method only this entity and |
394
|
|
|
* the cascade-persist semantics + scheduled inserts/removals are synchronized. |
395
|
|
|
* |
396
|
|
|
* @param null|object|array $entity The entity to be synchronized |
397
|
|
|
* |
398
|
|
|
* @return void |
399
|
|
|
* |
400
|
|
|
* @throws \Doctrine\ORM\OptimisticLockException If a version check on an entity that |
401
|
|
|
* makes use of optimistic locking fails. |
402
|
|
|
*/ |
403
|
|
|
public function flush($entity = null) |
404
|
|
|
{ |
405
|
|
|
return $this->__call('flush', array($entity)); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
/** |
409
|
|
|
* Gets the EventManager used by the EntityManager. |
410
|
|
|
* |
411
|
|
|
* @return \Doctrine\Common\EventManager The event manager |
412
|
|
|
*/ |
413
|
|
|
public function getEventManager() |
414
|
|
|
{ |
415
|
|
|
return $this->__call('getEventManager', array()); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* Gets the Configuration used by the EntityManager. |
420
|
|
|
* |
421
|
|
|
* @return \Doctrine\ORM\Configuration The configuration |
422
|
|
|
*/ |
423
|
|
|
public function getConfiguration() |
424
|
|
|
{ |
425
|
|
|
return $this->__call('getConfiguration', array()); |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* Check if the Entity manager is open or closed. |
430
|
|
|
* |
431
|
|
|
* @return boolean TRUE if the EM is open |
432
|
|
|
*/ |
433
|
|
|
public function isOpen() |
434
|
|
|
{ |
435
|
|
|
return $this->__call('isOpen', array()); |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* Gets the UnitOfWork used by the EntityManager to coordinate operations. |
440
|
|
|
* |
441
|
|
|
* @return \Doctrine\ORM\UnitOfWork The unit of work |
442
|
|
|
*/ |
443
|
|
|
public function getUnitOfWork() |
444
|
|
|
{ |
445
|
|
|
return $this->__call('getUnitOfWork', array()); |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* Gets a hydrator for the given hydration mode. |
450
|
|
|
* |
451
|
|
|
* This method caches the hydrator instances which is used for all queries that don't |
452
|
|
|
* selectively iterate over the result. |
453
|
|
|
* |
454
|
|
|
* @param int $hydrationMode The hydration mode to use |
455
|
|
|
* |
456
|
|
|
* @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator |
457
|
|
|
* @deprecated |
458
|
|
|
*/ |
459
|
|
|
public function getHydrator($hydrationMode) |
460
|
|
|
{ |
461
|
|
|
return $this->__call('getHydrator', array($hydrationMode)); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Create a new instance for the given hydration mode. |
466
|
|
|
* |
467
|
|
|
* @param integer $hydrationMode The hydration mode to use |
468
|
|
|
* |
469
|
|
|
* @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator |
470
|
|
|
* @throws \Doctrine\ORM\ORMException |
471
|
|
|
*/ |
472
|
|
|
public function newHydrator($hydrationMode) |
473
|
|
|
{ |
474
|
|
|
return $this->__call('newHydtrator', array($hydrationMode)); |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Gets the proxy factory used by the EntityManager to create entity proxies. |
479
|
|
|
* |
480
|
|
|
* @return \Doctrine\ORM\Proxy\ProxyFactory The proxy factory |
481
|
|
|
*/ |
482
|
|
|
public function getProxyFactory() |
483
|
|
|
{ |
484
|
|
|
return $this->__call('getProxyFactory', array()); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Gets the enabled filters. |
489
|
|
|
* |
490
|
|
|
* @return \Doctrine\ORM\Query\FilterCollection The active filter collection |
491
|
|
|
*/ |
492
|
|
|
public function getFilters() |
493
|
|
|
{ |
494
|
|
|
return $this->__call('getFilters', array()); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* Checks whether the state of the filter collection is clean. |
499
|
|
|
* |
500
|
|
|
* @return boolean TRUE, if the filter collection is clean |
501
|
|
|
*/ |
502
|
|
|
public function isFiltersStateClean() |
503
|
|
|
{ |
504
|
|
|
return $this->__call('isFiltersStateClean', array()); |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* Checks whether the Entity Manager has filters. |
509
|
|
|
* |
510
|
|
|
* @return boolean TRUE, if the EM has a filter collection |
511
|
|
|
*/ |
512
|
|
|
public function hasFilters() |
513
|
|
|
{ |
514
|
|
|
return $this->__call('hasFilters', array()); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled. |
519
|
|
|
* |
520
|
|
|
* @return \Doctrine\ORM\Cache|null |
521
|
|
|
*/ |
522
|
|
|
public function getCache() |
523
|
|
|
{ |
524
|
|
|
return $this->__call('getCache', array()); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
/** |
528
|
|
|
* Tells the ObjectManager to make an instance managed and persistent. |
529
|
|
|
* |
530
|
|
|
* The object will be entered into the database as a result of the flush operation. |
531
|
|
|
* |
532
|
|
|
* NOTE: The persist operation always considers objects that are not yet known to |
533
|
|
|
* this ObjectManager as NEW. Do not pass detached objects to the persist operation. |
534
|
|
|
* |
535
|
|
|
* @param object $object The instance to make managed and persistent. |
536
|
|
|
* |
537
|
|
|
* @return void |
538
|
|
|
*/ |
539
|
|
|
public function persist($object) |
540
|
|
|
{ |
541
|
|
|
return $this->__call('persist', array($object)); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* Removes an object instance. |
546
|
|
|
* |
547
|
|
|
* A removed object will be removed from the database as a result of the flush operation. |
548
|
|
|
* |
549
|
|
|
* @param object $object The object instance to remove. |
550
|
|
|
* |
551
|
|
|
* @return void |
552
|
|
|
*/ |
553
|
|
|
public function remove($object) |
554
|
|
|
{ |
555
|
|
|
return $this->__call('remove', array($object)); |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Merges the state of a detached object into the persistence context |
560
|
|
|
* of this ObjectManager and returns the managed copy of the object. |
561
|
|
|
* The object passed to merge will not become associated/managed with this ObjectManager. |
562
|
|
|
* |
563
|
|
|
* @param object $object The object to be merged |
564
|
|
|
* |
565
|
|
|
* @return object The merge instance |
566
|
|
|
*/ |
567
|
|
|
public function merge($object) |
568
|
|
|
{ |
569
|
|
|
return $this->__call('merge', array($object)); |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
/** |
573
|
|
|
* Clears the ObjectManager. All objects that are currently managed |
574
|
|
|
* by this ObjectManager become detached. |
575
|
|
|
* |
576
|
|
|
* @param string|null $objectName if given, only objects of this type will get detached. |
577
|
|
|
* |
578
|
|
|
* @return void |
579
|
|
|
*/ |
580
|
|
|
public function clear($objectName = null) |
581
|
|
|
{ |
582
|
|
|
return $this->__call('clear', array($objectName)); |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* Detaches an object from the ObjectManager, causing a managed object to |
587
|
|
|
* become detached. Unflushed changes made to the object if any |
588
|
|
|
* (including removal of the object), will not be synchronized to the database. |
589
|
|
|
* Objects which previously referenced the detached object will continue to |
590
|
|
|
* reference it. |
591
|
|
|
* |
592
|
|
|
* @param object $object The object to detach. |
593
|
|
|
* |
594
|
|
|
* @return void |
595
|
|
|
*/ |
596
|
|
|
public function detach($object) |
597
|
|
|
{ |
598
|
|
|
return $this->__call('detach', array($object)); |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
/** |
602
|
|
|
* Refreshes the persistent state of an object from the database, |
603
|
|
|
* overriding any local changes that have not yet been persisted. |
604
|
|
|
* |
605
|
|
|
* @param object $object The object to refresh. |
606
|
|
|
* |
607
|
|
|
* @return void |
608
|
|
|
*/ |
609
|
|
|
public function refresh($object) |
610
|
|
|
{ |
611
|
|
|
return $this->__call('refresh', array($object)); |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
/** |
615
|
|
|
* Gets the repository for a class. |
616
|
|
|
* |
617
|
|
|
* @param string $className The class name to return the repository for |
618
|
|
|
* |
619
|
|
|
* @return \Doctrine\Common\Persistence\ObjectRepository |
620
|
|
|
*/ |
621
|
|
|
public function getRepository($className) |
622
|
|
|
{ |
623
|
|
|
return $this->__call('getRepository', array($className)); |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
/** |
627
|
|
|
* Returns the ClassMetadata descriptor for a class. |
628
|
|
|
* |
629
|
|
|
* The class name must be the fully-qualified class name without a leading backslash |
630
|
|
|
* (as it is returned by get_class($obj)). |
631
|
|
|
* |
632
|
|
|
* @param string $className The class name to return the metadata for |
633
|
|
|
* |
634
|
|
|
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadata |
635
|
|
|
*/ |
636
|
|
|
public function getClassMetadata($className) |
637
|
|
|
{ |
638
|
|
|
return $this->__call('getClassMetadata', array($className)); |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
/** |
642
|
|
|
* Gets the metadata factory used to gather the metadata of classes. |
643
|
|
|
* |
644
|
|
|
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory |
645
|
|
|
*/ |
646
|
|
|
public function getMetadataFactory() |
647
|
|
|
{ |
648
|
|
|
return $this->__call('getMetadataFactory', array()); |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Helper method to initialize a lazy loading proxy or persistent collection. |
653
|
|
|
* |
654
|
|
|
* This method is a no-op for other objects. |
655
|
|
|
* |
656
|
|
|
* @param object $obj The object to be initialized |
657
|
|
|
* |
658
|
|
|
* @return void |
659
|
|
|
*/ |
660
|
|
|
public function initializeObject($obj) |
661
|
|
|
{ |
662
|
|
|
return $this->__call('initializeObject', array($obj)); |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* Checks if the object is part of the current UnitOfWork and therefore managed. |
667
|
|
|
* |
668
|
|
|
* @param object $object The object to check |
669
|
|
|
* |
670
|
|
|
* @return bool |
671
|
|
|
*/ |
672
|
|
|
public function contains($object) |
673
|
|
|
{ |
674
|
|
|
return $this->__call('contains', array($object)); |
675
|
|
|
} |
676
|
|
|
} |
677
|
|
|
|