/**
  * Create a new instance for the given hydration mode.
  *
  * @param  int $hydrationMode
  * @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator
  */
 public function newHydrator($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;
         case Query::HYDRATE_SIMPLEOBJECT:
             $hydrator = new Internal\Hydration\SimpleObjectHydrator($this);
             break;
         default:
             if ($class = $this->config->getCustomHydrationMode($hydrationMode)) {
                 $hydrator = new $class($this);
                 break;
             }
             throw ORMException::invalidHydrationMode($hydrationMode);
     }
     return $hydrator;
 }
Пример #2
0
 public function testSetCustomHydrationModes()
 {
     $this->configuration->addCustomHydrationMode('HydrationModeName', __CLASS__);
     $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName'));
     $this->configuration->setCustomHydrationModes(array('AnotherHydrationModeName' => __CLASS__));
     $this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName'));
     $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('AnotherHydrationModeName'));
 }