public function process(FormRuleProcessorContext $context, FormRuleContextBuilder $collection)
 {
     $form = $context->getForm();
     $formConfig = $form->getConfig();
     if (!$formConfig->getCompound()) {
         return;
     }
     $transformer = $this->findTransformer($formConfig, 'Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\ValueToDuplicatesTransformer');
     if ($transformer === null) {
         return;
     }
     $keys = $this->getKeys($transformer);
     if (empty($keys)) {
         return;
     }
     $formView = $context->getView();
     // Use children here since we need the full_name
     $primary = array_shift($keys);
     $primaryView = $formView->children[$primary];
     // Copy all rules to the first child/key element
     $ruleCollection = $collection->get($formView);
     if (!empty($ruleCollection)) {
         $collection->add($primaryView, $ruleCollection);
     }
     $collection->remove($formView);
     // Get correct error message if one is set.
     $invalidMessage = $this->getFormRuleMessage($formConfig);
     // Create equalTo rules for all other fields
     $equalToPrimaryRule = new TransformerRule('equalTo', FormHelper::generateCssSelector($primaryView), $invalidMessage, array(new FieldDependency($primaryView)));
     foreach ($keys as $childName) {
         $childCollection = new RuleCollection();
         $childCollection->set('equalTo', $equalToPrimaryRule);
         $collection->add($formView->children[$childName], $childCollection);
     }
 }
 private function cleanChildRules(FormView $childView, FormRuleContextBuilder $formRuleContext)
 {
     $rules = $formRuleContext->get($childView);
     if ($rules === null) {
         return;
     }
     // Don't remove transformer rules!
     foreach ($rules as $name => $rule) {
         if (!$rule instanceof ConstraintRule) {
             continue;
         }
         $rules->remove($name);
     }
     if (empty($rules)) {
         $formRuleContext->remove($childView);
     }
 }
 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;
 }