AggregateHydrator.php in Zircon Profile 8
File
vendor/zendframework/zend-hydrator/src/Aggregate/AggregateHydrator.php
View source
<?php
namespace Zend\Hydrator\Aggregate;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\Hydrator\HydratorInterface;
class AggregateHydrator implements HydratorInterface, EventManagerAwareInterface {
const DEFAULT_PRIORITY = 1;
protected $eventManager;
public function add(HydratorInterface $hydrator, $priority = self::DEFAULT_PRIORITY) {
$this
->getEventManager()
->attachAggregate(new HydratorListener($hydrator), $priority);
}
public function extract($object) {
$event = new ExtractEvent($this, $object);
$this
->getEventManager()
->trigger($event);
return $event
->getExtractedData();
}
public function hydrate(array $data, $object) {
$event = new HydrateEvent($this, $object, $data);
$this
->getEventManager()
->trigger($event);
return $event
->getHydratedObject();
}
public function setEventManager(EventManagerInterface $eventManager) {
$eventManager
->setIdentifiers([
__CLASS__,
get_class($this),
]);
$this->eventManager = $eventManager;
}
public function getEventManager() {
if (null === $this->eventManager) {
$this
->setEventManager(new EventManager());
}
return $this->eventManager;
}
}