/**
  * Callback to be used when {@see \Zend\Stdlib\Hydrator\Aggregate\ExtractEvent::EVENT_EXTRACT} is triggered
  *
  * @param \Zend\Stdlib\Hydrator\Aggregate\ExtractEvent $event
  *
  * @return array
  *
  * @internal
  */
 public function onExtract(ExtractEvent $event)
 {
     $data = $this->hydrator->extract($event->getExtractionObject());
     $event->mergeExtractedData($data);
     return $data;
 }
Beispiel #2
0
 /**
  * @covers \Zend\Stdlib\Hydrator\Aggregate\ExtractEvent
  */
 public function testEvent()
 {
     $target = new stdClass();
     $object1 = new stdClass();
     $event = new ExtractEvent($target, $object1);
     $data2 = array('maintainer' => 'Marvin');
     $object2 = new stdClass();
     $this->assertSame(ExtractEvent::EVENT_EXTRACT, $event->getName());
     $this->assertSame($target, $event->getTarget());
     $this->assertSame($object1, $event->getExtractionObject());
     $this->assertSame(array(), $event->getExtractedData());
     $event->setExtractedData($data2);
     $this->assertSame($data2, $event->getExtractedData());
     $event->setExtractionObject($object2);
     $this->assertSame($object2, $event->getExtractionObject());
     $event->mergeExtractedData(array('president' => 'Zaphod'));
     $extracted = $event->getExtractedData();
     $this->assertCount(2, $extracted);
     $this->assertSame('Marvin', $extracted['maintainer']);
     $this->assertSame('Zaphod', $extracted['president']);
 }