PageRenderTime 67ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Doctrine/ORM/UnitOfWork.php

https://github.com/stephaneerard/doctrine2
PHP | 3048 lines | 1594 code | 502 blank | 952 comment | 300 complexity | d3331c8db0c0134261ccb6562e783398 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\ORM;
  20. use Exception;
  21. use InvalidArgumentException;
  22. use UnexpectedValueException;
  23. use Doctrine\Common\Collections\ArrayCollection;
  24. use Doctrine\Common\Collections\Collection;
  25. use Doctrine\Common\NotifyPropertyChanged;
  26. use Doctrine\Common\PropertyChangedListener;
  27. use Doctrine\Common\Persistence\ObjectManagerAware;
  28. use Doctrine\ORM\Event\LifecycleEventArgs;
  29. use Doctrine\ORM\Mapping\ClassMetadata;
  30. use Doctrine\ORM\Proxy\Proxy;
  31. /**
  32. * The UnitOfWork is responsible for tracking changes to objects during an
  33. * "object-level" transaction and for writing out changes to the database
  34. * in the correct order.
  35. *
  36. * @since 2.0
  37. * @author Benjamin Eberlei <kontakt@beberlei.de>
  38. * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
  39. * @author Jonathan Wage <jonwage@gmail.com>
  40. * @author Roman Borschel <roman@code-factory.org>
  41. * @internal This class contains highly performance-sensitive code.
  42. */
  43. class UnitOfWork implements PropertyChangedListener
  44. {
  45. /**
  46. * An entity is in MANAGED state when its persistence is managed by an EntityManager.
  47. */
  48. const STATE_MANAGED = 1;
  49. /**
  50. * An entity is new if it has just been instantiated (i.e. using the "new" operator)
  51. * and is not (yet) managed by an EntityManager.
  52. */
  53. const STATE_NEW = 2;
  54. /**
  55. * A detached entity is an instance with persistent state and identity that is not
  56. * (or no longer) associated with an EntityManager (and a UnitOfWork).
  57. */
  58. const STATE_DETACHED = 3;
  59. /**
  60. * A removed entity instance is an instance with a persistent identity,
  61. * associated with an EntityManager, whose persistent state will be deleted
  62. * on commit.
  63. */
  64. const STATE_REMOVED = 4;
  65. /**
  66. * The identity map that holds references to all managed entities that have
  67. * an identity. The entities are grouped by their class name.
  68. * Since all classes in a hierarchy must share the same identifier set,
  69. * we always take the root class name of the hierarchy.
  70. *
  71. * @var array
  72. */
  73. private $identityMap = array();
  74. /**
  75. * Map of all identifiers of managed entities.
  76. * Keys are object ids (spl_object_hash).
  77. *
  78. * @var array
  79. */
  80. private $entityIdentifiers = array();
  81. /**
  82. * Map of the original entity data of managed entities.
  83. * Keys are object ids (spl_object_hash). This is used for calculating changesets
  84. * at commit time.
  85. *
  86. * @var array
  87. * @internal Note that PHPs "copy-on-write" behavior helps a lot with memory usage.
  88. * A value will only really be copied if the value in the entity is modified
  89. * by the user.
  90. */
  91. private $originalEntityData = array();
  92. /**
  93. * Map of entity changes. Keys are object ids (spl_object_hash).
  94. * Filled at the beginning of a commit of the UnitOfWork and cleaned at the end.
  95. *
  96. * @var array
  97. */
  98. private $entityChangeSets = array();
  99. /**
  100. * The (cached) states of any known entities.
  101. * Keys are object ids (spl_object_hash).
  102. *
  103. * @var array
  104. */
  105. private $entityStates = array();
  106. /**
  107. * Map of entities that are scheduled for dirty checking at commit time.
  108. * This is only used for entities with a change tracking policy of DEFERRED_EXPLICIT.
  109. * Keys are object ids (spl_object_hash).
  110. *
  111. * @var array
  112. * @todo rename: scheduledForSynchronization
  113. */
  114. private $scheduledForDirtyCheck = array();
  115. /**
  116. * A list of all pending entity insertions.
  117. *
  118. * @var array
  119. */
  120. private $entityInsertions = array();
  121. /**
  122. * A list of all pending entity updates.
  123. *
  124. * @var array
  125. */
  126. private $entityUpdates = array();
  127. /**
  128. * Any pending extra updates that have been scheduled by persisters.
  129. *
  130. * @var array
  131. */
  132. private $extraUpdates = array();
  133. /**
  134. * A list of all pending entity deletions.
  135. *
  136. * @var array
  137. */
  138. private $entityDeletions = array();
  139. /**
  140. * All pending collection deletions.
  141. *
  142. * @var array
  143. */
  144. private $collectionDeletions = array();
  145. /**
  146. * All pending collection updates.
  147. *
  148. * @var array
  149. */
  150. private $collectionUpdates = array();
  151. /**
  152. * List of collections visited during changeset calculation on a commit-phase of a UnitOfWork.
  153. * At the end of the UnitOfWork all these collections will make new snapshots
  154. * of their data.
  155. *
  156. * @var array
  157. */
  158. private $visitedCollections = array();
  159. /**
  160. * The EntityManager that "owns" this UnitOfWork instance.
  161. *
  162. * @var \Doctrine\ORM\EntityManager
  163. */
  164. private $em;
  165. /**
  166. * The calculator used to calculate the order in which changes to
  167. * entities need to be written to the database.
  168. *
  169. * @var \Doctrine\ORM\Internal\CommitOrderCalculator
  170. */
  171. private $commitOrderCalculator;
  172. /**
  173. * The entity persister instances used to persist entity instances.
  174. *
  175. * @var array
  176. */
  177. private $persisters = array();
  178. /**
  179. * The collection persister instances used to persist collections.
  180. *
  181. * @var array
  182. */
  183. private $collectionPersisters = array();
  184. /**
  185. * The EventManager used for dispatching events.
  186. *
  187. * @var \Doctrine\Common\EventManager
  188. */
  189. private $evm;
  190. /**
  191. * Orphaned entities that are scheduled for removal.
  192. *
  193. * @var array
  194. */
  195. private $orphanRemovals = array();
  196. /**
  197. * Read-Only objects are never evaluated
  198. *
  199. * @var array
  200. */
  201. private $readOnlyObjects = array();
  202. /**
  203. * Map of Entity Class-Names and corresponding IDs that should eager loaded when requested.
  204. *
  205. * @var array
  206. */
  207. private $eagerLoadingEntities = array();
  208. /**
  209. * Initializes a new UnitOfWork instance, bound to the given EntityManager.
  210. *
  211. * @param \Doctrine\ORM\EntityManager $em
  212. */
  213. public function __construct(EntityManager $em)
  214. {
  215. $this->em = $em;
  216. $this->evm = $em->getEventManager();
  217. }
  218. /**
  219. * Commits the UnitOfWork, executing all operations that have been postponed
  220. * up to this point. The state of all managed entities will be synchronized with
  221. * the database.
  222. *
  223. * The operations are executed in the following order:
  224. *
  225. * 1) All entity insertions
  226. * 2) All entity updates
  227. * 3) All collection deletions
  228. * 4) All collection updates
  229. * 5) All entity deletions
  230. *
  231. * @param null|object|array $entity
  232. *
  233. * @throws \Exception
  234. *
  235. * @return void
  236. */
  237. public function commit($entity = null)
  238. {
  239. // Raise preFlush
  240. if ($this->evm->hasListeners(Events::preFlush)) {
  241. $this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->em));
  242. }
  243. // Compute changes done since last commit.
  244. if ($entity === null) {
  245. $this->computeChangeSets();
  246. } elseif (is_object($entity)) {
  247. $this->computeSingleEntityChangeSet($entity);
  248. } elseif (is_array($entity)) {
  249. foreach ($entity as $object) {
  250. $this->computeSingleEntityChangeSet($object);
  251. }
  252. }
  253. if ( ! ($this->entityInsertions ||
  254. $this->entityDeletions ||
  255. $this->entityUpdates ||
  256. $this->collectionUpdates ||
  257. $this->collectionDeletions ||
  258. $this->orphanRemovals)) {
  259. return; // Nothing to do.
  260. }
  261. if ($this->orphanRemovals) {
  262. foreach ($this->orphanRemovals as $orphan) {
  263. $this->remove($orphan);
  264. }
  265. }
  266. // Raise onFlush
  267. if ($this->evm->hasListeners(Events::onFlush)) {
  268. $this->evm->dispatchEvent(Events::onFlush, new Event\OnFlushEventArgs($this->em));
  269. }
  270. // Now we need a commit order to maintain referential integrity
  271. $commitOrder = $this->getCommitOrder();
  272. $conn = $this->em->getConnection();
  273. $conn->beginTransaction();
  274. try {
  275. if ($this->entityInsertions) {
  276. foreach ($commitOrder as $class) {
  277. $this->executeInserts($class);
  278. }
  279. }
  280. if ($this->entityUpdates) {
  281. foreach ($commitOrder as $class) {
  282. $this->executeUpdates($class);
  283. }
  284. }
  285. // Extra updates that were requested by persisters.
  286. if ($this->extraUpdates) {
  287. $this->executeExtraUpdates();
  288. }
  289. // Collection deletions (deletions of complete collections)
  290. foreach ($this->collectionDeletions as $collectionToDelete) {
  291. $this->getCollectionPersister($collectionToDelete->getMapping())->delete($collectionToDelete);
  292. }
  293. // Collection updates (deleteRows, updateRows, insertRows)
  294. foreach ($this->collectionUpdates as $collectionToUpdate) {
  295. $this->getCollectionPersister($collectionToUpdate->getMapping())->update($collectionToUpdate);
  296. }
  297. // Entity deletions come last and need to be in reverse commit order
  298. if ($this->entityDeletions) {
  299. for ($count = count($commitOrder), $i = $count - 1; $i >= 0; --$i) {
  300. $this->executeDeletions($commitOrder[$i]);
  301. }
  302. }
  303. $conn->commit();
  304. } catch (Exception $e) {
  305. $this->em->close();
  306. $conn->rollback();
  307. throw $e;
  308. }
  309. // Take new snapshots from visited collections
  310. foreach ($this->visitedCollections as $coll) {
  311. $coll->takeSnapshot();
  312. }
  313. // Raise postFlush
  314. if ($this->evm->hasListeners(Events::postFlush)) {
  315. $this->evm->dispatchEvent(Events::postFlush, new Event\PostFlushEventArgs($this->em));
  316. }
  317. // Clear up
  318. $this->entityInsertions =
  319. $this->entityUpdates =
  320. $this->entityDeletions =
  321. $this->extraUpdates =
  322. $this->entityChangeSets =
  323. $this->collectionUpdates =
  324. $this->collectionDeletions =
  325. $this->visitedCollections =
  326. $this->scheduledForDirtyCheck =
  327. $this->orphanRemovals = array();
  328. }
  329. /**
  330. * Compute the changesets of all entities scheduled for insertion
  331. *
  332. * @return void
  333. */
  334. private function computeScheduleInsertsChangeSets()
  335. {
  336. foreach ($this->entityInsertions as $entity) {
  337. $class = $this->em->getClassMetadata(get_class($entity));
  338. $this->computeChangeSet($class, $entity);
  339. }
  340. }
  341. /**
  342. * Only flush the given entity according to a ruleset that keeps the UoW consistent.
  343. *
  344. * 1. All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well!
  345. * 2. Read Only entities are skipped.
  346. * 3. Proxies are skipped.
  347. * 4. Only if entity is properly managed.
  348. *
  349. * @param object $entity
  350. *
  351. * @throws \InvalidArgumentException
  352. *
  353. * @return void
  354. */
  355. private function computeSingleEntityChangeSet($entity)
  356. {
  357. if ( $this->getEntityState($entity) !== self::STATE_MANAGED) {
  358. throw new \InvalidArgumentException("Entity has to be managed for single computation " . self::objToStr($entity));
  359. }
  360. $class = $this->em->getClassMetadata(get_class($entity));
  361. if ($class->isChangeTrackingDeferredImplicit()) {
  362. $this->persist($entity);
  363. }
  364. // Compute changes for INSERTed entities first. This must always happen even in this case.
  365. $this->computeScheduleInsertsChangeSets();
  366. if ($class->isReadOnly) {
  367. return;
  368. }
  369. // Ignore uninitialized proxy objects
  370. if ($entity instanceof Proxy && ! $entity->__isInitialized__) {
  371. return;
  372. }
  373. // Only MANAGED entities that are NOT SCHEDULED FOR INSERTION are processed here.
  374. $oid = spl_object_hash($entity);
  375. if ( ! isset($this->entityInsertions[$oid]) && isset($this->entityStates[$oid])) {
  376. $this->computeChangeSet($class, $entity);
  377. }
  378. }
  379. /**
  380. * Executes any extra updates that have been scheduled.
  381. */
  382. private function executeExtraUpdates()
  383. {
  384. foreach ($this->extraUpdates as $oid => $update) {
  385. list ($entity, $changeset) = $update;
  386. $this->entityChangeSets[$oid] = $changeset;
  387. $this->getEntityPersister(get_class($entity))->update($entity);
  388. }
  389. }
  390. /**
  391. * Gets the changeset for an entity.
  392. *
  393. * @param object $entity
  394. *
  395. * @return array
  396. */
  397. public function getEntityChangeSet($entity)
  398. {
  399. $oid = spl_object_hash($entity);
  400. if (isset($this->entityChangeSets[$oid])) {
  401. return $this->entityChangeSets[$oid];
  402. }
  403. return array();
  404. }
  405. /**
  406. * Computes the changes that happened to a single entity.
  407. *
  408. * Modifies/populates the following properties:
  409. *
  410. * {@link _originalEntityData}
  411. * If the entity is NEW or MANAGED but not yet fully persisted (only has an id)
  412. * then it was not fetched from the database and therefore we have no original
  413. * entity data yet. All of the current entity data is stored as the original entity data.
  414. *
  415. * {@link _entityChangeSets}
  416. * The changes detected on all properties of the entity are stored there.
  417. * A change is a tuple array where the first entry is the old value and the second
  418. * entry is the new value of the property. Changesets are used by persisters
  419. * to INSERT/UPDATE the persistent entity state.
  420. *
  421. * {@link _entityUpdates}
  422. * If the entity is already fully MANAGED (has been fetched from the database before)
  423. * and any changes to its properties are detected, then a reference to the entity is stored
  424. * there to mark it for an update.
  425. *
  426. * {@link _collectionDeletions}
  427. * If a PersistentCollection has been de-referenced in a fully MANAGED entity,
  428. * then this collection is marked for deletion.
  429. *
  430. * @ignore
  431. * @internal Don't call from the outside.
  432. * @param ClassMetadata $class The class descriptor of the entity.
  433. * @param object $entity The entity for which to compute the changes.
  434. */
  435. public function computeChangeSet(ClassMetadata $class, $entity)
  436. {
  437. $oid = spl_object_hash($entity);
  438. if (isset($this->readOnlyObjects[$oid])) {
  439. return;
  440. }
  441. if ( ! $class->isInheritanceTypeNone()) {
  442. $class = $this->em->getClassMetadata(get_class($entity));
  443. }
  444. // Fire PreFlush lifecycle callbacks
  445. if (isset($class->lifecycleCallbacks[Events::preFlush])) {
  446. $class->invokeLifecycleCallbacks(Events::preFlush, $entity);
  447. }
  448. $actualData = array();
  449. foreach ($class->reflFields as $name => $refProp) {
  450. $value = $refProp->getValue($entity);
  451. if ($class->isCollectionValuedAssociation($name) && $value !== null && ! ($value instanceof PersistentCollection)) {
  452. // If $value is not a Collection then use an ArrayCollection.
  453. if ( ! $value instanceof Collection) {
  454. $value = new ArrayCollection($value);
  455. }
  456. $assoc = $class->associationMappings[$name];
  457. // Inject PersistentCollection
  458. $value = new PersistentCollection(
  459. $this->em, $this->em->getClassMetadata($assoc['targetEntity']), $value
  460. );
  461. $value->setOwner($entity, $assoc);
  462. $value->setDirty( ! $value->isEmpty());
  463. $class->reflFields[$name]->setValue($entity, $value);
  464. $actualData[$name] = $value;
  465. continue;
  466. }
  467. if (( ! $class->isIdentifier($name) || ! $class->isIdGeneratorIdentity()) && ($name !== $class->versionField)) {
  468. $actualData[$name] = $value;
  469. }
  470. }
  471. if ( ! isset($this->originalEntityData[$oid])) {
  472. // Entity is either NEW or MANAGED but not yet fully persisted (only has an id).
  473. // These result in an INSERT.
  474. $this->originalEntityData[$oid] = $actualData;
  475. $changeSet = array();
  476. foreach ($actualData as $propName => $actualValue) {
  477. if ( ! isset($class->associationMappings[$propName])) {
  478. $changeSet[$propName] = array(null, $actualValue);
  479. continue;
  480. }
  481. $assoc = $class->associationMappings[$propName];
  482. if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
  483. $changeSet[$propName] = array(null, $actualValue);
  484. }
  485. }
  486. $this->entityChangeSets[$oid] = $changeSet;
  487. } else {
  488. // Entity is "fully" MANAGED: it was already fully persisted before
  489. // and we have a copy of the original data
  490. $originalData = $this->originalEntityData[$oid];
  491. $isChangeTrackingNotify = $class->isChangeTrackingNotify();
  492. $changeSet = ($isChangeTrackingNotify && isset($this->entityChangeSets[$oid]))
  493. ? $this->entityChangeSets[$oid]
  494. : array();
  495. foreach ($actualData as $propName => $actualValue) {
  496. // skip field, its a partially omitted one!
  497. if ( ! (isset($originalData[$propName]) || array_key_exists($propName, $originalData))) {
  498. continue;
  499. }
  500. $orgValue = $originalData[$propName];
  501. // skip if value havent changed
  502. if ($orgValue === $actualValue) {
  503. continue;
  504. }
  505. // if regular field
  506. if ( ! isset($class->associationMappings[$propName])) {
  507. if ($isChangeTrackingNotify) {
  508. continue;
  509. }
  510. $changeSet[$propName] = array($orgValue, $actualValue);
  511. continue;
  512. }
  513. $assoc = $class->associationMappings[$propName];
  514. // Persistent collection was exchanged with the "originally"
  515. // created one. This can only mean it was cloned and replaced
  516. // on another entity.
  517. if ($actualValue instanceof PersistentCollection) {
  518. $owner = $actualValue->getOwner();
  519. if ($owner === null) { // cloned
  520. $actualValue->setOwner($entity, $assoc);
  521. } else if ($owner !== $entity) { // no clone, we have to fix
  522. if (!$actualValue->isInitialized()) {
  523. $actualValue->initialize(); // we have to do this otherwise the cols share state
  524. }
  525. $newValue = clone $actualValue;
  526. $newValue->setOwner($entity, $assoc);
  527. $class->reflFields[$propName]->setValue($entity, $newValue);
  528. }
  529. }
  530. if ($orgValue instanceof PersistentCollection) {
  531. // A PersistentCollection was de-referenced, so delete it.
  532. $coid = spl_object_hash($orgValue);
  533. if (isset($this->collectionDeletions[$coid])) {
  534. continue;
  535. }
  536. $this->collectionDeletions[$coid] = $orgValue;
  537. $changeSet[$propName] = $orgValue; // Signal changeset, to-many assocs will be ignored.
  538. continue;
  539. }
  540. if ($assoc['type'] & ClassMetadata::TO_ONE) {
  541. if ($assoc['isOwningSide']) {
  542. $changeSet[$propName] = array($orgValue, $actualValue);
  543. }
  544. if ($orgValue !== null && $assoc['orphanRemoval']) {
  545. $this->scheduleOrphanRemoval($orgValue);
  546. }
  547. }
  548. }
  549. if ($changeSet) {
  550. $this->entityChangeSets[$oid] = $changeSet;
  551. $this->originalEntityData[$oid] = $actualData;
  552. $this->entityUpdates[$oid] = $entity;
  553. }
  554. }
  555. // Look for changes in associations of the entity
  556. foreach ($class->associationMappings as $field => $assoc) {
  557. if (($val = $class->reflFields[$field]->getValue($entity)) !== null) {
  558. $this->computeAssociationChanges($assoc, $val);
  559. if (!isset($this->entityChangeSets[$oid]) &&
  560. $assoc['isOwningSide'] &&
  561. $assoc['type'] == ClassMetadata::MANY_TO_MANY &&
  562. $val instanceof PersistentCollection &&
  563. $val->isDirty()) {
  564. $this->entityChangeSets[$oid] = array();
  565. $this->originalEntityData[$oid] = $actualData;
  566. $this->entityUpdates[$oid] = $entity;
  567. }
  568. }
  569. }
  570. }
  571. /**
  572. * Computes all the changes that have been done to entities and collections
  573. * since the last commit and stores these changes in the _entityChangeSet map
  574. * temporarily for access by the persisters, until the UoW commit is finished.
  575. */
  576. public function computeChangeSets()
  577. {
  578. // Compute changes for INSERTed entities first. This must always happen.
  579. $this->computeScheduleInsertsChangeSets();
  580. // Compute changes for other MANAGED entities. Change tracking policies take effect here.
  581. foreach ($this->identityMap as $className => $entities) {
  582. $class = $this->em->getClassMetadata($className);
  583. // Skip class if instances are read-only
  584. if ($class->isReadOnly) {
  585. continue;
  586. }
  587. // If change tracking is explicit or happens through notification, then only compute
  588. // changes on entities of that type that are explicitly marked for synchronization.
  589. switch (true) {
  590. case ($class->isChangeTrackingDeferredImplicit()):
  591. $entitiesToProcess = $entities;
  592. break;
  593. case (isset($this->scheduledForDirtyCheck[$className])):
  594. $entitiesToProcess = $this->scheduledForDirtyCheck[$className];
  595. break;
  596. default:
  597. $entitiesToProcess = array();
  598. }
  599. foreach ($entitiesToProcess as $entity) {
  600. // Ignore uninitialized proxy objects
  601. if ($entity instanceof Proxy && ! $entity->__isInitialized__) {
  602. continue;
  603. }
  604. // Only MANAGED entities that are NOT SCHEDULED FOR INSERTION are processed here.
  605. $oid = spl_object_hash($entity);
  606. if ( ! isset($this->entityInsertions[$oid]) && isset($this->entityStates[$oid])) {
  607. $this->computeChangeSet($class, $entity);
  608. }
  609. }
  610. }
  611. }
  612. /**
  613. * Computes the changes of an association.
  614. *
  615. * @param array $assoc
  616. * @param mixed $value The value of the association.
  617. *
  618. * @throws ORMInvalidArgumentException
  619. * @throws ORMException
  620. *
  621. * @return void
  622. */
  623. private function computeAssociationChanges($assoc, $value)
  624. {
  625. if ($value instanceof Proxy && ! $value->__isInitialized__) {
  626. return;
  627. }
  628. if ($value instanceof PersistentCollection && $value->isDirty()) {
  629. $coid = spl_object_hash($value);
  630. if ($assoc['isOwningSide']) {
  631. $this->collectionUpdates[$coid] = $value;
  632. }
  633. $this->visitedCollections[$coid] = $value;
  634. }
  635. // Look through the entities, and in any of their associations,
  636. // for transient (new) entities, recursively. ("Persistence by reachability")
  637. // Unwrap. Uninitialized collections will simply be empty.
  638. $unwrappedValue = ($assoc['type'] & ClassMetadata::TO_ONE) ? array($value) : $value->unwrap();
  639. $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
  640. foreach ($unwrappedValue as $key => $entry) {
  641. $state = $this->getEntityState($entry, self::STATE_NEW);
  642. if ( ! ($entry instanceof $assoc['targetEntity'])) {
  643. throw new ORMException(
  644. sprintf(
  645. 'Found entity of type %s on association %s#%s, but expecting %s',
  646. get_class($entry),
  647. $assoc['sourceEntity'],
  648. $assoc['fieldName'],
  649. $targetClass->name
  650. )
  651. );
  652. }
  653. switch ($state) {
  654. case self::STATE_NEW:
  655. if ( ! $assoc['isCascadePersist']) {
  656. throw ORMInvalidArgumentException::newEntityFoundThroughRelationship($assoc, $entry);
  657. }
  658. $this->persistNew($targetClass, $entry);
  659. $this->computeChangeSet($targetClass, $entry);
  660. break;
  661. case self::STATE_REMOVED:
  662. // Consume the $value as array (it's either an array or an ArrayAccess)
  663. // and remove the element from Collection.
  664. if ($assoc['type'] & ClassMetadata::TO_MANY) {
  665. unset($value[$key]);
  666. }
  667. break;
  668. case self::STATE_DETACHED:
  669. // Can actually not happen right now as we assume STATE_NEW,
  670. // so the exception will be raised from the DBAL layer (constraint violation).
  671. throw ORMInvalidArgumentException::detachedEntityFoundThroughRelationship($assoc, $entry);
  672. break;
  673. default:
  674. // MANAGED associated entities are already taken into account
  675. // during changeset calculation anyway, since they are in the identity map.
  676. }
  677. }
  678. }
  679. /**
  680. * @param ClassMetadata $class
  681. * @param object $entity
  682. */
  683. private function persistNew($class, $entity)
  684. {
  685. $oid = spl_object_hash($entity);
  686. if (isset($class->lifecycleCallbacks[Events::prePersist])) {
  687. $class->invokeLifecycleCallbacks(Events::prePersist, $entity);
  688. }
  689. if ($this->evm->hasListeners(Events::prePersist)) {
  690. $this->evm->dispatchEvent(Events::prePersist, new LifecycleEventArgs($entity, $this->em));
  691. }
  692. $idGen = $class->idGenerator;
  693. if ( ! $idGen->isPostInsertGenerator()) {
  694. $idValue = $idGen->generate($this->em, $entity);
  695. if ( ! $idGen instanceof \Doctrine\ORM\Id\AssignedGenerator) {
  696. $idValue = array($class->identifier[0] => $idValue);
  697. $class->setIdentifierValues($entity, $idValue);
  698. }
  699. $this->entityIdentifiers[$oid] = $idValue;
  700. }
  701. $this->entityStates[$oid] = self::STATE_MANAGED;
  702. $this->scheduleForInsert($entity);
  703. }
  704. /**
  705. * INTERNAL:
  706. * Computes the changeset of an individual entity, independently of the
  707. * computeChangeSets() routine that is used at the beginning of a UnitOfWork#commit().
  708. *
  709. * The passed entity must be a managed entity. If the entity already has a change set
  710. * because this method is invoked during a commit cycle then the change sets are added.
  711. * whereby changes detected in this method prevail.
  712. *
  713. * @ignore
  714. * @param ClassMetadata $class The class descriptor of the entity.
  715. * @param object $entity The entity for which to (re)calculate the change set.
  716. *
  717. * @throws ORMInvalidArgumentException If the passed entity is not MANAGED.
  718. */
  719. public function recomputeSingleEntityChangeSet(ClassMetadata $class, $entity)
  720. {
  721. $oid = spl_object_hash($entity);
  722. if ( ! isset($this->entityStates[$oid]) || $this->entityStates[$oid] != self::STATE_MANAGED) {
  723. throw ORMInvalidArgumentException::entityNotManaged($entity);
  724. }
  725. // skip if change tracking is "NOTIFY"
  726. if ($class->isChangeTrackingNotify()) {
  727. return;
  728. }
  729. if ( ! $class->isInheritanceTypeNone()) {
  730. $class = $this->em->getClassMetadata(get_class($entity));
  731. }
  732. $actualData = array();
  733. foreach ($class->reflFields as $name => $refProp) {
  734. if ( ! $class->isIdentifier($name) || ! $class->isIdGeneratorIdentity()) {
  735. $actualData[$name] = $refProp->getValue($entity);
  736. }
  737. }
  738. $originalData = $this->originalEntityData[$oid];
  739. $changeSet = array();
  740. foreach ($actualData as $propName => $actualValue) {
  741. $orgValue = isset($originalData[$propName]) ? $originalData[$propName] : null;
  742. if (is_object($orgValue) && $orgValue !== $actualValue) {
  743. $changeSet[$propName] = array($orgValue, $actualValue);
  744. } else if ($orgValue != $actualValue || ($orgValue === null ^ $actualValue === null)) {
  745. $changeSet[$propName] = array($orgValue, $actualValue);
  746. }
  747. }
  748. if ($changeSet) {
  749. if (isset($this->entityChangeSets[$oid])) {
  750. $this->entityChangeSets[$oid] = array_merge($this->entityChangeSets[$oid], $changeSet);
  751. }
  752. $this->originalEntityData[$oid] = $actualData;
  753. }
  754. }
  755. /**
  756. * Executes all entity insertions for entities of the specified type.
  757. *
  758. * @param \Doctrine\ORM\Mapping\ClassMetadata $class
  759. */
  760. private function executeInserts($class)
  761. {
  762. $className = $class->name;
  763. $persister = $this->getEntityPersister($className);
  764. $entities = array();
  765. $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]);
  766. $hasListeners = $this->evm->hasListeners(Events::postPersist);
  767. foreach ($this->entityInsertions as $oid => $entity) {
  768. if ($this->em->getClassMetadata(get_class($entity))->name !== $className) {
  769. continue;
  770. }
  771. $persister->addInsert($entity);
  772. unset($this->entityInsertions[$oid]);
  773. if ($hasLifecycleCallbacks || $hasListeners) {
  774. $entities[] = $entity;
  775. }
  776. }
  777. $postInsertIds = $persister->executeInserts();
  778. if ($postInsertIds) {
  779. // Persister returned post-insert IDs
  780. foreach ($postInsertIds as $id => $entity) {
  781. $oid = spl_object_hash($entity);
  782. $idField = $class->identifier[0];
  783. $class->reflFields[$idField]->setValue($entity, $id);
  784. $this->entityIdentifiers[$oid] = array($idField => $id);
  785. $this->entityStates[$oid] = self::STATE_MANAGED;
  786. $this->originalEntityData[$oid][$idField] = $id;
  787. $this->addToIdentityMap($entity);
  788. }
  789. }
  790. foreach ($entities as $entity) {
  791. if ($hasLifecycleCallbacks) {
  792. $class->invokeLifecycleCallbacks(Events::postPersist, $entity);
  793. }
  794. if ($hasListeners) {
  795. $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entity, $this->em));
  796. }
  797. }
  798. }
  799. /**
  800. * Executes all entity updates for entities of the specified type.
  801. *
  802. * @param \Doctrine\ORM\Mapping\ClassMetadata $class
  803. */
  804. private function executeUpdates($class)
  805. {
  806. $className = $class->name;
  807. $persister = $this->getEntityPersister($className);
  808. $hasPreUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::preUpdate]);
  809. $hasPreUpdateListeners = $this->evm->hasListeners(Events::preUpdate);
  810. $hasPostUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postUpdate]);
  811. $hasPostUpdateListeners = $this->evm->hasListeners(Events::postUpdate);
  812. foreach ($this->entityUpdates as $oid => $entity) {
  813. if ($this->em->getClassMetadata(get_class($entity))->name !== $className) {
  814. continue;
  815. }
  816. if ($hasPreUpdateLifecycleCallbacks) {
  817. $class->invokeLifecycleCallbacks(Events::preUpdate, $entity);
  818. $this->recomputeSingleEntityChangeSet($class, $entity);
  819. }
  820. if ($hasPreUpdateListeners) {
  821. $this->evm->dispatchEvent(
  822. Events::preUpdate,
  823. new Event\PreUpdateEventArgs($entity, $this->em, $this->entityChangeSets[$oid])
  824. );
  825. }
  826. if (!empty($this->entityChangeSets[$oid])) {
  827. $persister->update($entity);
  828. }
  829. unset($this->entityUpdates[$oid]);
  830. if ($hasPostUpdateLifecycleCallbacks) {
  831. $class->invokeLifecycleCallbacks(Events::postUpdate, $entity);
  832. }
  833. if ($hasPostUpdateListeners) {
  834. $this->evm->dispatchEvent(Events::postUpdate, new LifecycleEventArgs($entity, $this->em));
  835. }
  836. }
  837. }
  838. /**
  839. * Executes all entity deletions for entities of the specified type.
  840. *
  841. * @param \Doctrine\ORM\Mapping\ClassMetadata $class
  842. */
  843. private function executeDeletions($class)
  844. {
  845. $className = $class->name;
  846. $persister = $this->getEntityPersister($className);
  847. $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postRemove]);
  848. $hasListeners = $this->evm->hasListeners(Events::postRemove);
  849. foreach ($this->entityDeletions as $oid => $entity) {
  850. if ($this->em->getClassMetadata(get_class($entity))->name !== $className) {
  851. continue;
  852. }
  853. $persister->delete($entity);
  854. unset(
  855. $this->entityDeletions[$oid],
  856. $this->entityIdentifiers[$oid],
  857. $this->originalEntityData[$oid],
  858. $this->entityStates[$oid]
  859. );
  860. // Entity with this $oid after deletion treated as NEW, even if the $oid
  861. // is obtained by a new entity because the old one went out of scope.
  862. //$this->entityStates[$oid] = self::STATE_NEW;
  863. if ( ! $class->isIdentifierNatural()) {
  864. $class->reflFields[$class->identifier[0]]->setValue($entity, null);
  865. }
  866. if ($hasLifecycleCallbacks) {
  867. $class->invokeLifecycleCallbacks(Events::postRemove, $entity);
  868. }
  869. if ($hasListeners) {
  870. $this->evm->dispatchEvent(Events::postRemove, new LifecycleEventArgs($entity, $this->em));
  871. }
  872. }
  873. }
  874. /**
  875. * Gets the commit order.
  876. *
  877. * @param array $entityChangeSet
  878. *
  879. * @return array
  880. */
  881. private function getCommitOrder(array $entityChangeSet = null)
  882. {
  883. if ($entityChangeSet === null) {
  884. $entityChangeSet = array_merge($this->entityInsertions, $this->entityUpdates, $this->entityDeletions);
  885. }
  886. $calc = $this->getCommitOrderCalculator();
  887. // See if there are any new classes in the changeset, that are not in the
  888. // commit order graph yet (dont have a node).
  889. // We have to inspect changeSet to be able to correctly build dependencies.
  890. // It is not possible to use IdentityMap here because post inserted ids
  891. // are not yet available.
  892. $newNodes = array();
  893. foreach ($entityChangeSet as $entity) {
  894. $className = $this->em->getClassMetadata(get_class($entity))->name;
  895. if ($calc->hasClass($className)) {
  896. continue;
  897. }
  898. $class = $this->em->getClassMetadata($className);
  899. $calc->addClass($class);
  900. $newNodes[] = $class;
  901. }
  902. // Calculate dependencies for new nodes
  903. while ($class = array_pop($newNodes)) {
  904. foreach ($class->associationMappings as $assoc) {
  905. if ( ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) {
  906. continue;
  907. }
  908. $targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
  909. if ( ! $calc->hasClass($targetClass->name)) {
  910. $calc->addClass($targetClass);
  911. $newNodes[] = $targetClass;
  912. }
  913. $calc->addDependency($targetClass, $class);
  914. // If the target class has mapped subclasses, these share the same dependency.
  915. if ( ! $targetClass->subClasses) {
  916. continue;
  917. }
  918. foreach ($targetClass->subClasses as $subClassName) {
  919. $targetSubClass = $this->em->getClassMetadata($subClassName);
  920. if ( ! $calc->hasClass($subClassName)) {
  921. $calc->addClass($targetSubClass);
  922. $newNodes[] = $targetSubClass;
  923. }
  924. $calc->addDependency($targetSubClass, $class);
  925. }
  926. }
  927. }
  928. return $calc->getCommitOrder();
  929. }
  930. /**
  931. * Schedules an entity for insertion into the database.
  932. * If the entity already has an identifier, it will be added to the identity map.
  933. *
  934. * @param object $entity The entity to schedule for insertion.
  935. *
  936. * @throws ORMInvalidArgumentException
  937. * @throws \InvalidArgumentException
  938. */
  939. public function scheduleForInsert($entity)
  940. {
  941. $oid = spl_object_hash($entity);
  942. if (isset($this->entityUpdates[$oid])) {
  943. throw new InvalidArgumentException("Dirty entity can not be scheduled for insertion.");
  944. }
  945. if (isset($this->entityDeletions[$oid])) {
  946. throw ORMInvalidArgumentException::scheduleInsertForRemovedEntity($entity);
  947. }
  948. if (isset($this->originalEntityData[$oid]) && ! isset($this->entityInsertions[$oid])) {
  949. throw ORMInvalidArgumentException::scheduleInsertForManagedEntity($entity);
  950. }
  951. if (isset($this->entityInsertions[$oid])) {
  952. throw ORMInvalidArgumentException::scheduleInsertTwice($entity);
  953. }
  954. $this->entityInsertions[$oid] = $entity;
  955. if (isset($this->entityIdentifiers[$oid])) {
  956. $this->addToIdentityMap($entity);
  957. }
  958. if ($entity instanceof NotifyPropertyChanged) {
  959. $entity->addPropertyChangedListener($this);
  960. }
  961. }
  962. /**
  963. * Checks whether an entity is scheduled for insertion.
  964. *
  965. * @param object $entity
  966. *
  967. * @return boolean
  968. */
  969. public function isScheduledForInsert($entity)
  970. {
  971. return isset($this->entityInsertions[spl_object_hash($entity)]);
  972. }
  973. /**
  974. * Schedules an entity for being updated.
  975. *
  976. * @param object $entity The entity to schedule for being updated.
  977. *
  978. * @throws ORMInvalidArgumentException
  979. */
  980. public function scheduleForUpdate($entity)
  981. {
  982. $oid = spl_object_hash($entity);
  983. if ( ! isset($this->entityIdentifiers[$oid])) {
  984. throw ORMInvalidArgumentException::entityHasNoIdentity($entity, "scheduling for update");
  985. }
  986. if (isset($this->entityDeletions[$oid])) {
  987. throw ORMInvalidArgumentException::entityIsRemoved($entity, "schedule for update");
  988. }
  989. if ( ! isset($this->entityUpdates[$oid]) && ! isset($this->entityInsertions[$oid])) {
  990. $this->entityUpdates[$oid] = $entity;
  991. }
  992. }
  993. /**
  994. * INTERNAL:
  995. * Schedules an extra update that will be executed immediately after the
  996. * regular entity updates within the currently running commit cycle.
  997. *
  998. * Extra updates for entities are stored as (entity, changeset) tuples.
  999. *
  1000. * @ignore
  1001. * @param object $entity The entity for which to schedule an extra update.
  1002. * @param array $changeset The changeset of the entity (what to update).
  1003. */
  1004. public function scheduleExtraUpdate($entity, array $changeset)
  1005. {
  1006. $oid = spl_object_hash($entity);
  1007. $extraUpdate = array($entity, $changeset);
  1008. if (isset($this->extraUpdates[$oid])) {
  1009. list($ignored, $changeset2) = $this->extraUpdates[$oid];
  1010. $extraUpdate = array($entity, $changeset + $changeset2);
  1011. }
  1012. $this->extraUpdates[$oid] = $extraUpdate;
  1013. }
  1014. /**
  1015. * Checks whether an entity is registered as dirty in the unit of work.
  1016. * Note: Is not very useful currently as dirty entities are only registered
  1017. * at commit time.
  1018. *
  1019. * @param object $entity
  1020. *
  1021. * @return boolean
  1022. */
  1023. public function isScheduledForUpdate($entity)
  1024. {
  1025. return isset($this->entityUpdates[spl_object_hash($entity)]);
  1026. }
  1027. /**
  1028. * Checks whether an entity is registered to be checked in the unit of work.
  1029. *
  1030. * @param object $entity
  1031. *
  1032. * @return boolean
  1033. */
  1034. public function isScheduledForDirtyCheck($entity)
  1035. {
  1036. $rootEntityName = $this->em->getClassMetadata(get_class($entity))->rootEntityName;
  1037. return isset($this->scheduledForDirtyCheck[$rootEntityName][spl_object_hash($entity)]);
  1038. }
  1039. /**
  1040. * INTERNAL:
  1041. * Schedules an entity for deletion.
  1042. *
  1043. * @param object $entity
  1044. */
  1045. public function scheduleForDelete($entity)
  1046. {
  1047. $oid = spl_object_hash($entity);
  1048. if (isset($this->entityInsertions[$oid])) {
  1049. if ($this->isInIdentityMap($entity)) {
  1050. $this->removeFromIdentityMap($entity);
  1051. }
  1052. unset($this->entityInsertions[$oid], $this->entityStates[$oid]);
  1053. return; // entity has not been persisted yet, so nothing more to do.
  1054. }
  1055. if ( ! $this->isInIdentityMap($entity)) {
  1056. return;
  1057. }
  1058. $this->removeFromIdentityMap($entity);
  1059. if (isset($this->entityUpdates[$oid])) {
  1060. unset($this->entityUpdates[$oid]);
  1061. }
  1062. if ( ! isset($this->entityDeletions[$oid])) {
  1063. $this->entityDeletions[$oid] = $entity;
  1064. $this->entityStates[$oid] = self::STATE_REMOVED;
  1065. }
  1066. }
  1067. /**
  1068. * Checks whether an entity is registered as removed/deleted with the unit
  1069. * of work.
  1070. *
  1071. * @param object $entity
  1072. *
  1073. * @return boolean
  1074. */
  1075. public function isScheduledForDelete($entity)
  1076. {
  1077. return isset($this->entityDeletions[spl_object_hash($entity)]);
  1078. }
  1079. /**
  1080. * Checks whether an entity is scheduled for insertion, update or deletion.
  1081. *
  1082. * @param $entity
  1083. *
  1084. * @return boolean
  1085. */
  1086. public function isEntityScheduled($entity)
  1087. {
  1088. $oid = spl_object_hash($entity);
  1089. return isset($this->entityInsertions[$oid])
  1090. || isset($this->entityUpdates[$oid])
  1091. || isset($this->entityDeletions[$oid]);
  1092. }
  1093. /**
  1094. * INTERNAL:
  1095. * Registers an entity in the identity map.
  1096. * Note that entities in a hierarchy are registered with the class name of
  1097. * the root entity.
  1098. *
  1099. * @ignore
  1100. * @param object $entity The entity to register.
  1101. *
  1102. * @throws ORMInvalidArgumentException
  1103. *
  1104. * @return boolean TRUE if the registration was successful, FALSE if the identity of
  1105. * the entity in question is already managed.
  1106. */
  1107. public function addToIdentityMap($entity)
  1108. {
  1109. $classMetadata = $this->em->getClassMetadata(get_class($entity));
  1110. $idHash = implode(' ', $this->entityIdentifiers[spl_object_hash($entity)]);
  1111. if ($idHash === '') {
  1112. throw ORMInvalidArgumentException::entityWithoutIdentity($classMetadata->name, $entity);
  1113. }
  1114. $className = $classMetadata->rootEntityName;
  1115. if (isset($this->identityMap[$className][$idHash])) {
  1116. return false;
  1117. }
  1118. $this->identityMap[$className][$idHash] = $entity;
  1119. return true;
  1120. }
  1121. /**
  1122. * Gets the state of an entity with regard to the current unit of work.
  1123. *
  1124. * @param object $entity
  1125. * @param integer $assume The state to assume if the state is not yet known (not MANAGED or REMOVED).
  1126. * This parameter can be set to improve performance of entity state detection
  1127. * by potentially avoiding a database lookup if the distinction between NEW and DETACHED
  1128. * is either known or does not matter for the caller of the method.
  1129. *
  1130. * @return int The entity state.
  1131. */
  1132. public function getEntityState($entity, $assume = null)
  1133. {
  1134. $oid = spl_object_hash($entity);
  1135. if (isset($this->entityStates[$oid])) {
  1136. return $this->entityStates[$oid];
  1137. }
  1138. if ($assume !== null) {
  1139. return $assume;
  1140. }
  1141. // State can only be NEW or DETACHED, because MANAGED/REMOVED states are known.
  1142. // Note that you can not remember the NEW or DETACHED state in _entityStates since
  1143. // the UoW does not hold references to such objects and the object hash can be reused.
  1144. // More generally because the state may "change" between NEW/DETACHED without the UoW being aware of it.
  1145. $class = $this->em->getClassMetadata(get_class($entity));
  1146. $id = $class->getIdentifierValues($entity);
  1147. if ( ! $id) {
  1148. return self::STATE_NEW;
  1149. }
  1150. switch (true) {
  1151. case ($class->isIdentifierNatural());
  1152. // Check for a version field, if available, to avoid a db lookup.
  1153. if ($class->isVersioned) {
  1154. return ($class->getFieldValue($entity, $class->versionField))
  1155. ? self::STATE_DETACHED
  1156. : self::STATE_NEW;
  1157. }
  1158. // Last try before db lookup: check the identity map.
  1159. if ($this->tryGetById($id, $class->rootEntityName)) {
  1160. return self::STATE_DETACHED;
  1161. }
  1162. // db lookup
  1163. if ($this->getEntityPersister($class->name)->exists($entity)) {
  1164. return self::STATE_DETACHED;
  1165. }
  1166. return self::STATE_NEW;
  1167. case ( ! $class->idGenerator->isPostInsertGenerator()):
  1168. // if we have a pre insert generator we can't be sure that having an id
  1169. // really means that the entity exists. We have to verify this through
  1170. // the last resort: a db lookup
  1171. // Last try before db lookup: check the identity map.
  1172. if ($this->tryGetById($id, $class->rootEntityName)) {
  1173. return self::STATE_DETACHED;
  1174. }
  1175. // db lookup
  1176. if ($this->getEntityPersister($class->name)->exists($entity)) {
  1177. return self::STATE_DETACHED;
  1178. }
  1179. return self::STATE_NEW;
  1180. default:
  1181. return self::STATE_DETACHED;
  1182. }
  1183. }
  1184. /**
  1185. * INTERNAL:
  1186. * Removes an entity from the identity map. This effectively detaches the
  1187. * entity from the persistence management of Doctrine.
  1188. *
  1189. * @ignore
  1190. * @param object $entity
  1191. *
  1192. * @throws ORMInvalidArgumentException
  1193. *
  1194. * @return boolean
  1195. */
  1196. public function removeFromIdentityMap($entity)
  1197. {
  1198. $oid = spl_object_hash($entity);
  1199. $classMetadata = $this->em->getClassMetadata(get_class($entity));
  1200. $idHash = implode(' ', $this->entityIdentifiers[$oid]);
  1201. if ($idHash === '') {
  1202. throw ORMInvalidArgumentException::entityHasNoIdentity($entity, "remove from identity map");
  1203. }
  1204. $className = $classMetadata->rootEntityName;
  1205. if (isset($this->identityMap[$className][$idHash])) {
  1206. unset($this->identityMap[$className][$idHash]);
  1207. unset($this->readOnlyObjects[$oid]);
  1208. //$this->entityStates[$oid] = self::STATE_DETACHED;
  1209. return true;
  1210. }
  1211. return false;
  1212. }
  1213. /**
  1214. * INTERNAL:
  1215. * Gets an entity in the identity map by its identifier hash.
  1216. *
  1217. * @ignore
  1218. * @param string $idHash
  1219. * @param string $rootCl…

Large files files are truncated, but you can click here to view the full file