Пример #1
0
 /**
  * @covers \Zend\Stdlib\Hydrator\Aggregate\HydrateEvent
  */
 public function testEvent()
 {
     $target = new stdClass();
     $hydrated1 = new stdClass();
     $data1 = array('president' => 'Zaphod');
     $event = new HydrateEvent($target, $hydrated1, $data1);
     $data2 = array('maintainer' => 'Marvin');
     $hydrated2 = new stdClass();
     $this->assertSame(HydrateEvent::EVENT_HYDRATE, $event->getName());
     $this->assertSame($target, $event->getTarget());
     $this->assertSame($hydrated1, $event->getHydratedObject());
     $this->assertSame($data1, $event->getHydrationData());
     $event->setHydrationData($data2);
     $this->assertSame($data2, $event->getHydrationData());
     $event->setHydratedObject($hydrated2);
     $this->assertSame($hydrated2, $event->getHydratedObject());
 }
Пример #2
0
 /**
  * Callback to be used when {@see \Zend\Stdlib\Hydrator\Aggregate\HydrateEvent::EVENT_HYDRATE} is triggered
  *
  * @param \Zend\Stdlib\Hydrator\Aggregate\HydrateEvent $event
  *
  * @return object
  *
  * @internal
  */
 public function onHydrate(HydrateEvent $event)
 {
     $object = $this->hydrator->hydrate($event->getHydrationData(), $event->getHydratedObject());
     $event->setHydratedObject($object);
     return $object;
 }