diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 6dda4d2f8..be1a0a1fb 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -296,12 +296,31 @@ abstract class AbstractQuery */ public function setResultSetMapping(Query\ResultSetMapping $rsm) { - $rsm->translateNamespaces($this->_em); + $this->translateNamespaces($rsm); $this->_resultSetMapping = $rsm; return $this; } + /** + * Allows to translate entity namespaces to full qualified names. + * + * @param EntityManager $em + * + * @return void + */ + private function translateNamespaces(Query\ResultSetMapping $rsm) + { + $entityManager = $this->_em; + + $translate = function ($alias) use ($entityManager) { + return $entityManager->getClassMetadata($alias)->getName(); + }; + + $rsm->aliasMap = array_map($translate, $rsm->aliasMap); + $rsm->declaringClasses = array_map($translate, $rsm->declaringClasses); + } + /** * Set a cache profile for hydration caching. * diff --git a/lib/Doctrine/ORM/Query/ResultSetMapping.php b/lib/Doctrine/ORM/Query/ResultSetMapping.php index 1461f4f4c..50dacea41 100644 --- a/lib/Doctrine/ORM/Query/ResultSetMapping.php +++ b/lib/Doctrine/ORM/Query/ResultSetMapping.php @@ -19,8 +19,6 @@ namespace Doctrine\ORM\Query; -use Doctrine\ORM\EntityManager; - /** * A ResultSetMapping describes how a result set of an SQL query maps to a Doctrine result. * @@ -545,27 +543,5 @@ class ResultSetMapping return $this; } - - /** - * Allows to translate entity namespaces to full qualified names. - * - * @param EntityManager $em - * - * @return void - */ - public function translateNamespaces(EntityManager $em) - { - $fqcn = array(); - - $translate = function (&$alias) use ($em, &$fqcn) { - if ( ! isset($fqcn[$alias])) { - $fqcn[$alias] = $em->getClassMetadata($alias)->getName(); - } - $alias = $fqcn[$alias]; - }; - - array_walk($this->aliasMap, $translate); - array_walk($this->declaringClasses, $translate); - } }