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);
     }
 }
 public function process(FormRuleProcessorContext $context, FormRuleContextBuilder $formRuleContext)
 {
     $form = $context->getForm();
     $formConfig = $form->getConfig();
     if (!$formConfig->getCompound()) {
         return;
     }
     /** @var \Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer $transformer */
     $transformer = $this->findTransformer($formConfig, 'Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\DateTimeToArrayTransformer');
     if ($transformer === null) {
         return;
     }
     $view = $context->getView();
     $fields = $this->getTransformerFields($transformer);
     $invalidMessage = $this->getFormRuleMessage($formConfig);
     $views = array();
     $conditions = array();
     foreach ($fields as $fieldName) {
         $childView = $view->children[$fieldName];
         // Get child rules collection
         $childRules = $formRuleContext->get($childView);
         if ($childRules === null) {
             $formRuleContext->add($childView, new RuleCollection());
             $childRules = $formRuleContext->get($childView);
         }
         // Register rules
         $this->addNumberCheck($childView, $childRules, $invalidMessage, $conditions);
         $views[] = FormHelper::getFormName($childView);
         $conditions[] = new FieldDependency($childView);
     }
     if ($this->useGroupRule && count($views) > 1) {
         $rules = $formRuleContext->get(array_shift($views));
         $rules->set(CompoundCopyToChildPass::RULE_NAME_GROUP_REQUIRED, new TransformerRule(CompoundCopyToChildPass::RULE_NAME_GROUP_REQUIRED, $views, $invalidMessage));
     }
 }
 public function process(FormRuleProcessorContext $context, FormRuleContextBuilder $formRuleContext)
 {
     $form = $context->getForm();
     $formConfig = $form->getConfig();
     if (!$formConfig->getCompound() || $context->getConstraints()->count() === 0) {
         return;
     }
     $formView = $context->getView();
     $rules = $formRuleContext->get($formView);
     if ($rules === null || $rules->count() === 0 || !$this->requiresCopy($form)) {
         return;
     }
     $this->registerRulesForChildren($formRuleContext, $formView, $this->getFormRuleMessage($formConfig));
 }
 public function process(FormRuleProcessorContext $processContext, FormRuleContextBuilder $formRuleContext)
 {
     $form = $processContext->getForm();
     if (!$this->requiresValidConstraint($form) || $this->hasValidConstraint($processContext->getConstraints())) {
         return;
     }
     $view = $processContext->getView();
     $it = new \RecursiveIteratorIterator(new FormViewRecursiveIterator($view->getIterator()), \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($it as $childView) {
         if (isset($childView->vars['required'])) {
             $childView->vars['required'] = false;
         }
         $this->cleanChildRules($childView, $formRuleContext);
     }
 }
 public function process(FormRuleProcessorContext $processContext, FormRuleContextBuilder $formRuleContext)
 {
     $constraints = $processContext->getConstraints();
     $form = $processContext->getForm();
     $collection = new RuleCollection();
     foreach ($this->mappers as $mapper) {
         foreach ($constraints as $constraint) {
             if (!$mapper->supports($constraint, $form)) {
                 continue;
             }
             $mapper->resolve($constraint, $form, $collection);
         }
     }
     $formRuleContext->add($processContext->getView(), $collection);
 }
 public function process(FormRuleProcessorContext $processContext, FormRuleContextBuilder $formRuleContext)
 {
     $form = $processContext->getForm();
     $view = $processContext->getView();
     // Check if this is a a prototype/collection type
     /** @var FormInterface|null $prototype */
     $prototype = $form->getConfig()->getAttribute('prototype');
     if (!$prototype || !isset($view->vars['prototype'])) {
         return;
     }
     /** @var FormView $prototypeView */
     $prototypeView = $view->vars['prototype'];
     // Extract the prototype rules from the default rules
     $prototypeContext = $this->extractRules($formRuleContext, $prototype, $prototypeView);
     if (count($prototypeContext->all()) === 0) {
         return;
     }
     // Register builder
     $view->vars['rule_builder'] = $prototypeContext;
 }
 public function process(FormRuleProcessorContext $context, FormRuleContextBuilder $formRuleContext)
 {
     $form = $context->getForm();
     $formConfig = $form->getConfig();
     if ($formConfig->getCompound()) {
         return;
     }
     if ($this->findTransformer($formConfig, 'Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\DateTimeToStringTransformer') === null && $this->findTransformer($formConfig, 'Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\DateTimeToRfc3339Transformer') === null) {
         return;
     }
     $formView = $context->getView();
     $formTypeClass = get_class($formConfig->getType()->getInnerType());
     switch ($formTypeClass) {
         case 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TimeType':
             $this->processTime($formView, $formConfig, $formRuleContext);
             return;
         case 'Symfony\\Component\\Form\\Extension\\Core\\Type\\DateType':
             $this->processDate($formView, $formConfig, $formRuleContext);
             return;
         case 'Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType':
             $this->processDateTime($formView, $formConfig, $formRuleContext);
             return;
     }
 }