Tweaking the method names of the recently added feature which allows custom hydration modes.
This commit is contained in:
parent
5b148c7b20
commit
bf9f7f85af
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -12,10 +12,11 @@ class CustomHydratorTest extends HydrationTestCase
|
||||
{
|
||||
$em = $this->_getTestEntityManager();
|
||||
$config = $em->getConfiguration();
|
||||
$config->addHydrator('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator');
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user