Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/9e9dd10633943efcf4c8 to your computer and use it in GitHub Desktop.
Save doctrinebot/9e9dd10633943efcf4c8 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-309 - https://github.com/doctrine/doctrine2/issues/3864
Index: lib/Doctrine/ORM/AbstractQuery.php
===================================================================
--- lib/Doctrine/ORM/AbstractQuery.php (revision 7124)
+++ lib/Doctrine/ORM/AbstractQuery.php (working copy)
@@ -456,7 +456,7 @@
*/
public function iterate(array $params = array(), $hydrationMode = self::HYDRATE_OBJECT)
{
- return $this->_em->getHydrator($this->_hydrationMode)->iterate(
+ return $this->_em->createHydrator($this->_hydrationMode)->iterate(
$this->_doExecute($params, $hydrationMode), $this->_resultSetMapping
);
}
Index: lib/Doctrine/ORM/EntityExistsException.php
===================================================================
--- lib/Doctrine/ORM/EntityExistsException.php (revision 0)
+++ lib/Doctrine/ORM/EntityExistsException.php (revision 0)
@@ -0,0 +1,24 @@
+<?php
+
+namespace Doctrine\ORM;
+
+/**
+ * EntityExistsException is thrown by EntityManager when a detached Entity is being persisted.
+ *
+ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
+ * @link www.doctrine-project.com
+ * @since 1.0
+ * @version $Revision$
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ */
+class EntityExistsException extends ORMException
+{
+ /**
+ * @param string $class
+ */
+ public function __construct($class)
+ {
+ parent::__construct("Entity of Type '".$class."' is already associated with the ".
+ "persistence context, you can't call persist() on it more than once.");
+ }
+}
\ No newline at end of file
Property changes on: lib/Doctrine/ORM/EntityExistsException.php
___________________________________________________________________
Added: svn:keywords
+ Id,Revision
Added: svn:eol-style
+ LF
Index: lib/Doctrine/ORM/EntityManager.php
===================================================================
--- lib/Doctrine/ORM/EntityManager.php (revision 7124)
+++ lib/Doctrine/ORM/EntityManager.php (working copy)
@@ -515,26 +515,32 @@
public function getHydrator($hydrationMode)
{
if ( ! isset($this->_hydrators[$hydrationMode])) {
- switch ($hydrationMode) {
- case Query::HYDRATE_OBJECT:
- $this->_hydrators[$hydrationMode] = new Internal\Hydration\ObjectHydrator($this);
- break;
- case Query::HYDRATE_ARRAY:
- $this->_hydrators[$hydrationMode] = new Internal\Hydration\ArrayHydrator($this);
- break;
- case Query::HYDRATE_SCALAR:
- $this->_hydrators[$hydrationMode] = new Internal\Hydration\ScalarHydrator($this);
- break;
- case Query::HYDRATE_SINGLE_SCALAR:
- $this->_hydrators[$hydrationMode] = new Internal\Hydration\SingleScalarHydrator($this);
- break;
- default:
- throw ORMException::invalidHydrationMode($hydrationMode);
- }
+ $this->_hydrators[$hydrationMode] = $this->createHydrator($hydrationMode);
}
return $this->_hydrators[$hydrationMode];
}
+ public function createHydrator($hydrationMode)
+ {
+ switch ($hydrationMode) {
+ case Query::HYDRATE_OBJECT:
+ $hydrator = new Internal\Hydration\ObjectHydrator($this);
+ break;
+ case Query::HYDRATE_ARRAY:
+ $hydrator = new Internal\Hydration\ArrayHydrator($this);
+ break;
+ case Query::HYDRATE_SCALAR:
+ $hydrator = new Internal\Hydration\ScalarHydrator($this);
+ break;
+ case Query::HYDRATE_SINGLE_SCALAR:
+ $hydrator = new Internal\Hydration\SingleScalarHydrator($this);
+ break;
+ default:
+ throw ORMException::invalidHydrationMode($hydrationMode);
+ }
+ return $hydrator;
+ }
+
/**
* Gets the proxy factory used by the EntityManager to create entity proxies.
*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment