From bf9f7f85afd00f60b5c39eb9c77b187f2a047008 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Thu, 3 Jun 2010 14:11:31 -0400 Subject: [PATCH] Tweaking the method names of the recently added feature which allows custom hydration modes. --- lib/Doctrine/ORM/Configuration.php | 23 ++++++++--------- lib/Doctrine/ORM/EntityManager.php | 2 +- .../ORM/Hydration/CustomHydratorTest.php | 25 ++++++++++--------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 102ab90df..75b66453e 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -464,26 +464,25 @@ class Configuration extends \Doctrine\DBAL\Configuration } /** - * Get a custom hydrator class name if it exists or return null if it - * does not. + * Get the hydrator class for the given hydration mode name. * - * @param string $name - * @return string $className + * @param string $modeName The hydration mode name. + * @return string $hydrator The hydrator class name. */ - public function getHydrator($name) + public function getCustomHydrationMode($modeName) { - return isset($this->_attributes['customHydrators'][$name]) ? - $this->_attributes['customHydrators'][$name] : null; + return isset($this->_attributes['customHydrationModes'][$modeName]) ? + $this->_attributes['customHydrationModes'][$modeName] : null; } /** - * Add a hydrator class associated with a hydration mode name. + * Add a custom hydration mode. * - * @param string $name The name of the hydration mode. - * @param string $class The class name associated with the name. + * @param string $modeName The hydration mode name. + * @param string $hydrator The hydrator class name. */ - public function addHydrator($name, $class) + public function addCustomHydrationMode($modeName, $hydrator) { - $this->_attributes['customHydrators'][$name] = $class; + $this->_attributes['customHydrationModes'][$modeName] = $hydrator; } } \ No newline at end of file diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 660e10ba9..566c353c2 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -616,7 +616,7 @@ class EntityManager $hydrator = new Internal\Hydration\SingleScalarHydrator($this); break; default: - if ($class = $this->_config->getHydrator($hydrationMode)) { + if ($class = $this->_config->getCustomHydrationMode($hydrationMode)) { $hydrator = new $class($this); break; } diff --git a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php index a7ef599ea..6b5e45149 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/CustomHydratorTest.php @@ -8,21 +8,22 @@ require_once __DIR__ . '/../../TestInit.php'; class CustomHydratorTest extends HydrationTestCase { - public function testCustomHydrator() - { - $em = $this->_getTestEntityManager(); - $config = $em->getConfiguration(); - $config->addHydrator('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator'); - - $hydrator = $em->newHydrator('CustomHydrator'); - $this->assertTrue($hydrator instanceof \Doctrine\Tests\ORM\Hydration\CustomHydrator); - } + public function testCustomHydrator() + { + $em = $this->_getTestEntityManager(); + $config = $em->getConfiguration(); + $config->addCustomHydrationMode('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator'); + + $hydrator = $em->newHydrator('CustomHydrator'); + $this->assertTrue($hydrator instanceof \Doctrine\Tests\ORM\Hydration\CustomHydrator); + $this->assertNull($config->getCustomHydrationMode('does not exist')); + } } class CustomHydrator extends AbstractHydrator { - protected function _hydrateAll() + protected function _hydrateAll() { - return $this->_stmt->fetchAll(PDO::FETCH_ASSOC); - } + return $this->_stmt->fetchAll(PDO::FETCH_ASSOC); + } } \ No newline at end of file