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
|
* Get the hydrator class for the given hydration mode name.
|
||||||
* does not.
|
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $modeName The hydration mode name.
|
||||||
* @return string $className
|
* @return string $hydrator The hydrator class name.
|
||||||
*/
|
*/
|
||||||
public function getHydrator($name)
|
public function getCustomHydrationMode($modeName)
|
||||||
{
|
{
|
||||||
return isset($this->_attributes['customHydrators'][$name]) ?
|
return isset($this->_attributes['customHydrationModes'][$modeName]) ?
|
||||||
$this->_attributes['customHydrators'][$name] : null;
|
$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 $modeName The hydration mode name.
|
||||||
* @param string $class The class name associated with the 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);
|
$hydrator = new Internal\Hydration\SingleScalarHydrator($this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($class = $this->_config->getHydrator($hydrationMode)) {
|
if ($class = $this->_config->getCustomHydrationMode($hydrationMode)) {
|
||||||
$hydrator = new $class($this);
|
$hydrator = new $class($this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,11 @@ class CustomHydratorTest extends HydrationTestCase
|
|||||||
{
|
{
|
||||||
$em = $this->_getTestEntityManager();
|
$em = $this->_getTestEntityManager();
|
||||||
$config = $em->getConfiguration();
|
$config = $em->getConfiguration();
|
||||||
$config->addHydrator('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator');
|
$config->addCustomHydrationMode('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator');
|
||||||
|
|
||||||
$hydrator = $em->newHydrator('CustomHydrator');
|
$hydrator = $em->newHydrator('CustomHydrator');
|
||||||
$this->assertTrue($hydrator instanceof \Doctrine\Tests\ORM\Hydration\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