0
爲什麼人們在事件訂閱事件中使用FormFactory?爲什麼在事件訂閱事件中使用FormFactory?
我現在有一個事件的用戶是這樣的...
public static function getSubscribedEvents()
{
return array(
FormEvent::PRE_SET_DATA => 'doSomething',
);
}
public function doSomething(FormEvent $event)
{
$form = $event->getForm();
... /// other stuff, see below /// ...
}
目前我然後用..
$form->add('field', 'type', options);
但很多其他開發人員使用的形式工廠..
$form->add($formFactory->createNamed('field', 'type', null, options);
兩者都似乎工作,所以使用額外的窗體工廠對象的原因是什麼?
很酷。所以只要我不關心向後兼容性,我可以忘記額外的'$ formFactory'東西。乾杯。 – qooplmao