protected function extractRules(FormRuleContextBuilder $formRuleContext, FormInterface $form, FormView $view) { $extracted = new FormRuleContextBuilder(); if ($form->getConfig()->getCompound()) { $it = new \RecursiveIteratorIterator(new FormViewRecursiveIterator($view->getIterator()), \RecursiveIteratorIterator::SELF_FIRST); $found = array(); foreach ($it as $childView) { $found[] = FormHelper::getFormName($childView); } } else { $found = array($view); } foreach ($found as $foundView) { $rules = $formRuleContext->get($foundView); if ($rules === null) { continue; } $extracted->add($foundView, $rules); $formRuleContext->remove($foundView); } return $extracted; }
/** * @param \Symfony\Component\Form\FormView $formView */ public function __construct(FormView $formView) { $this->iterator = $formView->getIterator(); }
/** * @param \Symfony\Component\Form\FormView $formView * * @return array */ protected function getFormDataFromResult(FormView $formView) { $customerData = []; foreach ($formView->getIterator() as $item) { $customerData[$item->vars['name']] = $item->vars['value']; } return $customerData; }