0
聚集水合器能嵌套嗎?如果我有以下類:zf2 - 嵌套聚集體水化器
class Appointment{
public date;
public startTime;
public endTime;
public User; //* @var User */
}
class User{
public Location; //* @var Location*/
}
...被填充了以下AggregateHydrator(從工廠創建):
class AppointmentModelHydratorFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator) {
$serviceManager = $serviceLocator->getServiceLocator();
$arrayHydrator = new ArraySerializable();
$arrayHydrator->addStrategy('date', new DateTimeStrategy())
->addStrategy('endTime', new TimeStrategy())
->addStrategy('startTime', new TimeStrategy());
$aggregateHydrator = new AggregateHydrator();
$aggregateHydrator->add($arrayHydrator);
$aggregateHydrator->add($serviceLocator->get('Hydrator\User'));
return $aggregateHydrator;
}
}
隨着UserHydratorFactory看起來像:
class UserHydratorFactory implements FactoryInterface
{
public function createService(ServiceLocatorInterface $serviceLocator) {
$sm = $serviceLocator->getServiceLocator();
$userHydrator = new UserHydrator($sm->get('User\Mapper'));
$aggregateHydrator = new AggregateHydrator();
$aggregateHydrator->add($userHydrator);
$aggregateHydrator->add($sm->get('HydratorManager')->get('Hydrator\User\Location'));
return $aggregateHydrator;
}
}
這是拋出一個期望,因爲模型返回爲null,但我我註釋了將位置水合器添加到用戶水合器,它工作正常(雖然沒有位置數據加載)。所以我想知道聚合水合器是否可以嵌套?