Example #1
0
 /**
  * @param OptionsResolverInterface $resolver
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Bruvinsky\\HighschoolBundle\\Entity\\Subject'));
     //        $params = [
     //            'class' => 'Bruvinsky\HighschoolBundle\Entity\Subject',
     //            'compound' => true,
     //            'multiple' => true,
     //            'expanded' => true,
     //            'property' => 'name',
     //        ];
     //        if (!empty($this->choiceList['documentList'])) {
     //            // this is used in form "show" mode
     //            $params['choices'] = $this->choiceList;
     //        } elseif (!empty($this->choiceList['idList'])) {
     //            // this is used on the form validation
     //            $idList = $this->choiceList['idList'];
     //            $params['query_builder'] = function ($repo) use ($idList) {
     //                return $repo->createQueryBuilder()
     //                    ->field('id')->in($idList);
     //            };
     //        } else {
     //            #$params['choices'] = [];
     //        }
     //        $resolver->setDefaults($params);
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultFieldOptions = ['multiple' => true];
     $resolver->setDefaults(['dictionary_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions]);
     $resolver->setNormalizers(['class' => function (Options $options, $value) {
         if ($value !== null) {
             return $value;
         }
         if (empty($options['dictionary_code'])) {
             throw new InvalidOptionsException('Either "class" or "dictionary_code" must option must be set.');
         }
         $class = ExtendHelper::buildEnumValueClassName($options['dictionary_code']);
         if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
             throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
         }
         return $class;
     }, 'field_options' => function (Options $options, $value) use(&$defaultFieldOptions) {
         if (isset($options['class'])) {
             $nullValue = null;
             if ($options->has('null_value')) {
                 $nullValue = $options->get('null_value');
             }
             $value['choices'] = $this->getChoices($options['class'], $nullValue);
         } else {
             $value['choices'] = [];
         }
         return array_merge($defaultFieldOptions, $value);
     }]);
 }
 function it_should_configure_the_resolver(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('format' => Argument::any(), 'language' => \Locale::getDefault(), 'leading_zero' => false))->shouldBeCalled();
     $resolver->setOptional(array('placeholder', 'language', 'leading_zero'))->shouldBeCalled();
     $resolver->setAllowedTypes(array('placeholder' => array('string'), 'language' => array('string'), 'leading_zero' => array('bool')))->shouldBeCalled();
     $this->setDefaultOptions($resolver);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $emptyData = function (FormInterface $form, $clientData) {
         return $clientData;
     };
     $resolver->setDefaults(array('value' => '1', 'empty_data' => $emptyData, 'compound' => false));
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Barbon\\HostedApi\\AppBundle\\Form\\Common\\Model\\BankAccount', 'validation_groups' => function (FormInterface $form) {
         $validationGroup = new BankAccountValidationGroupSelector();
         return $validationGroup->chooseGroups($form);
     }));
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['name', 'label']);
     $resolver->setOptional(['rows', 'comment', 'suffix', 'prefix', 'selector', 'wrap', 'class', 'css_attribute', 'max_length', 'error', 'rules', 'filters', 'dependencies', 'default', 'property_path', 'transformer']);
     $resolver->setDefaults(['dependencies' => [], 'filters' => [], 'rules' => [], 'transformer' => null, 'property_path' => null]);
     $resolver->setAllowedTypes(['name' => 'string', 'rows' => 'int', 'label' => 'string', 'comment' => 'string', 'suffix' => 'string', 'prefix' => 'string', 'selector' => 'string', 'wrap' => 'string', 'class' => 'string', 'css_attribute' => 'string', 'max_length' => 'integer', 'error' => 'string', 'filters' => 'array', 'rules' => 'array', 'dependencies' => 'array', 'default' => ['string', 'integer']]);
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $class = get_class($this);
     $class = substr($class, strlen('Kaikmedia\\GalleryModule\\Form\\Features\\'));
     $class = substr($class, 0, -strlen('Type'));
     $resolver->setDefaults(['data_class' => 'Kaikmedia\\GalleryModule\\Features\\' . $class]);
 }
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $compound = function (Options $options) {
         return isset($options['parent']) ? $options['parent'] : 'hidden';
     };
     $resolver->setDefaults(array('compound' => $compound, 'model_manager' => null, 'class' => null));
 }
 /**
  * {@inheritdoc}
  */
 public function run(OptionsResolverInterface $resolver)
 {
     $records = array();
     $localRecords = $this->localSource->execute();
     $results = $this->ridicSource->execute();
     foreach ($results as $key => $result) {
         $result = array_change_key_case($result, CASE_LOWER);
         $mrn = $result['hup_mrn'];
         try {
             $result['previous_record'] = $this->provider->getPatientByMRN($mrn);
         } catch (PatientNotFoundException $e) {
             unset($result, $results[$key]);
             continue;
         }
         $result['identifier'] = $result['course_ser'];
         $result['patient'] = $result['hup_mrn'];
         $result['activity_date'] = $result['first_treatment_dt'];
         $result['import_description'] = sprintf('%s ridic dose on the %s.', $result['course_ser'], $result['hup_mrn']);
         $record = $resolver->resolve($result);
         if ($record['patient'] && !in_array($record['course_ser'], $localRecords)) {
             $records[] = $record;
         }
         unset($results[$key]);
     }
     return $records;
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('class' => $this->dataClass, 'property' => 'canonical', 'label' => 'accard.diagnosis.entity_name', 'query_builder' => function (EntityRepository $er) {
         static $qb;
         return $qb = $er->getQueryBuilder();
     }, 'empty_value' => 'accard.diagnosis.form.select_diagnosis'));
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['rows_per_page', 'key']);
     $resolver->setOptional(['default_sorting', 'right_click_menu', 'auto_suggest_delay', 'auto_suggest_min_length', 'auto_suggest_suggestions', 'only_one_selected', 'no_column_modification', 'no_column_resizing', 'create_input', 'save_column_modification', 'persistent']);
     $resolver->setDefaults(['rows_per_page' => 50, 'key' => 'id']);
     $resolver->setAllowedTypes(['rows_per_page' => 'int', 'key' => ['int', 'string'], 'default_sorting' => ['int', 'string'], 'right_click_menu' => 'bool', 'auto_suggest_delay' => 'int', 'auto_suggest_min_length' => 'int', 'auto_suggest_suggestions' => 'int', 'only_one_selected' => 'bool', 'no_column_modification' => 'bool', 'no_column_resizing' => 'bool', 'create_input' => 'bool', 'save_column_modification' => 'bool', 'persistent' => 'bool']);
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     if (!$this->channelClass) {
         throw new \InvalidArgumentException('Channel class is missing');
     }
     $queryBuilderNormalizer = function (Options $options, $qb) {
         /** @var EntityManager $em */
         $em = $options['em'];
         /** @var EntityRepository $repository */
         $repository = $em->getRepository($this->channelClass);
         $entities = $options->get('entities');
         /** @var QueryBuilder $queryBuilder */
         $queryBuilder = $qb($repository, $entities);
         $queryBuilder->join('c.dataSource', 'd')->andWhere($queryBuilder->expr()->andX($queryBuilder->expr()->eq('d.type', ':type'), $queryBuilder->expr()->eq('d.enabled', ':enabled')))->setParameter('type', ChannelType::TYPE)->setParameter('enabled', true);
         $filteredQb = clone $queryBuilder;
         /** @var Channel[] $channels */
         $channels = $filteredQb->getQuery()->getResult();
         $skipEntities = [];
         foreach ($channels as $channel) {
             $dataSource = $channel->getDataSource();
             if (!(bool) $dataSource->getSynchronizationSettings()->offsetGetOr('isTwoWaySyncEnabled')) {
                 $skipEntities[] = $channel->getId();
             }
         }
         if ($skipEntities) {
             $queryBuilder->andWhere($queryBuilder->expr()->notIn('c.id', ':skipEntities'))->setParameter('skipEntities', $skipEntities);
         }
         return $queryBuilder;
     };
     $resolver->setNormalizers(['query_builder' => $queryBuilderNormalizer]);
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('em' => null, 'property' => null, 'queryBuilder' => null, 'multiple' => true, 'values_delimiter' => ','))->setAllowedValues(array('multiple' => array(true, false)));
     $resolver->setRequired(array('class'));
     $registry = $this->registry;
     $emNormalizer = function (Options $options, $em) use($registry) {
         if (null !== $em) {
             if ($em instanceof EntityManager) {
                 return $em;
             } elseif (is_string($em)) {
                 $em = $registry->getManager($em);
             } else {
                 throw new FormException(sprintf('Option "em" should be a string or entity manager object, %s given', is_object($em) ? get_class($em) : gettype($em)));
             }
         } else {
             $em = $registry->getManagerForClass($options['class']);
         }
         if (null === $em) {
             throw new FormException(sprintf('Class "%s" is not a managed Doctrine entity. Did you forget to map it?', $options['class']));
         }
         return $em;
     };
     $queryBuilderNormalizer = function (Options $options, $queryBuilder) {
         if (null !== $queryBuilder && !is_callable($queryBuilder)) {
             throw new FormException(sprintf('Option "queryBuilder" should be a callable, %s given', is_object($queryBuilder) ? get_class($queryBuilder) : gettype($queryBuilder)));
         }
         return $queryBuilder;
     };
     $resolver->setNormalizers(array('em' => $emNormalizer, 'queryBuilder' => $queryBuilderNormalizer));
 }
Example #14
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['multiple' => true, 'expanded' => true, 'choices' => $this->getChoices()]);
     $resolver->setNormalizers(['disabled' => function (Options $options, $value) {
         return $this->isReadOnly($options) ? true : $value;
     }]);
 }
 /**
  * {@inheritDoc}
  */
 public function setOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['forced', 'origin', 'feed', 'date_locale', 'number_locale', 'default_values']);
     $resolver->setAllowedValues(['date_locale' => ['en', 'nl'], 'number_locale' => ['en', 'nl']]);
     $resolver->setAllowedTypes(['forced' => 'bool', 'origin' => 'FM\\IoBundle\\Model\\OriginInterface', 'feed' => 'FM\\IoBundle\\Entity\\Feed', 'default_values' => 'array']);
     $resolver->setDefaults(['forced' => false, 'date_locale' => 'en', 'number_locale' => 'en', 'default_values' => []]);
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('constraints' => [new Assert\NotBlank()]));
     $constraintsNormalizer = function (Options $options, $constraints) {
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $options['config_id'];
         if (!$this->typeHelper->hasEnumCode($fieldConfigId->getClassName(), $fieldConfigId->getFieldName())) {
             // validations of new enum
             $constraints[] = new Assert\Length(['max' => $this->nameGenerator->getMaxEnumCodeSize()]);
             $constraints[] = new Assert\Regex(['pattern' => '/^[\\w- ]*$/', 'message' => self::INVALID_NAME_MESSAGE]);
             $callback = function ($value, ExecutionContext $context) {
                 if (!empty($value)) {
                     $code = ExtendHelper::buildEnumCode($value, false);
                     if (empty($code)) {
                         $context->addViolation(self::INVALID_NAME_MESSAGE, ['{{ value }}' => $value]);
                     }
                 }
             };
             $constraints[] = new Assert\Callback([$callback]);
             $constraints[] = new UniqueEnumName(['entityClassName' => $fieldConfigId->getClassName(), 'fieldName' => $fieldConfigId->getFieldName()]);
         } else {
             // validations of existing enum
             $constraints[] = new Assert\Length(['max' => 255]);
         }
         return $constraints;
     };
     $resolver->setNormalizers(['constraints' => $constraintsNormalizer, 'disabled' => function (Options $options, $value) {
         return $this->isReadOnly($options) ? true : $value;
     }, 'validation_groups' => function (Options $options, $value) {
         return $options['disabled'] ? false : $value;
     }]);
 }
Example #17
0
 /**
  * @see Symfony\Component\Form\AbstractType::setDefaultOptions()
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     /* Note: the form's intention must correspond to that for the form login
      * listener in order for the CSRF token to validate successfully.
      */
     $resolver->setDefaults(array('intention' => 'authenticate'));
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['name', 'label', 'property_path']);
     $resolver->setOptional(['class', 'error', 'comment', 'default', 'filters', 'rules', 'transformer']);
     $resolver->setDefaults(['dependencies' => [], 'filters' => [], 'rules' => [], 'property_path' => null, 'transformer' => null]);
     $resolver->setAllowedTypes(['name' => 'string', 'label' => 'string', 'class' => 'string', 'error' => 'string', 'comment' => 'string', 'default' => ['string', 'integer'], 'property_path' => ['null', 'object'], 'transformer' => ['null', 'object']]);
 }
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('data_class' => 'Matthias\\User\\App\\Command\\RegisterUserCommand', 'empty_data' => function (FormInterface $form) {
         $command = new RegisterUserCommand($form->get('username')->getData(), $form->get('password')->getData());
         return $command;
     }));
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaults = array('pickDate' => 'true', 'pickTime' => 'false', 'useMinutes' => 'false', 'useSeconds' => 'false', 'useCurrent' => 'true', 'minuteStepping' => '1', 'minDate' => '1/1/1900', 'maxDate' => '""', 'showToday' => 'false', 'language' => 'en', 'defaultDate' => '""', 'disabledDates' => '[]', 'enabledDates' => '[]', 'useStrict' => 'false', 'sideBySide' => 'false', 'daysOfWeekDisabled' => '[]', 'dateFormat' => 'YYYY-MM-DD', 'filter' => false);
     $resolver->setDefaults(array('widget' => 'single_text', 'Zk2DateTimeSetting' => $defaults))->setNormalizers(array('Zk2DateTimeSetting' => function (Options $options, $configs) use($defaults) {
         return array_merge($defaults, $configs);
     }));
 }
Example #21
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['bundle', 'level']);
     $resolver->setDefaults(['multiple' => true, 'expanded' => true, 'label_attr' => ['class' => 'control-label'], 'attr' => function (Options $options) {
         return ['data-permission' => $options['bundle'] . ':' . $options['level'], 'onchange' => 'Mautic.onPermissionChange(this, \'' . $options['bundle'] . '\')'];
     }]);
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $that = $this;
     $resolver->setDefaults(array('category' => null, 'choice_list' => function (Options $opts, $previousValue) use($that) {
         return new SimpleChoiceList($that->getChoices($opts));
     }));
 }
Example #23
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $choiceList = function (Options $options) {
         return new ObjectChoiceList($options['option']->getValues(), 'value', array(), null, 'id', PropertyAccess::createPropertyAccessor());
     };
     $resolver->setDefaults(array('choice_list' => $choiceList))->setRequired(array('option'))->addAllowedTypes(array('option' => 'Sylius\\Component\\Variation\\Model\\OptionInterface'));
 }
Example #24
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $contexts = $this->contexts;
     $manager = $this->manager;
     $resolver->setDefaults(array('context' => false, 'multiple' => false, 'expanded' => false, 'choices' => function (Options $options, $previousValue) use($contexts, $manager) {
         if (!isset($contexts[$options['context']])) {
             if (Kernel::MINOR_VERSION < 3) {
                 throw new \RuntimeException(sprintf('Invalid context: `%s`', $options['context']));
             }
             throw new InvalidArgumentException(sprintf('Invalid context: `%s`', $options['context']));
         }
         $types = array();
         foreach ($contexts[$options['context']] as $service) {
             $types[$service] = sprintf('%s - %s', $manager->getService($service)->getName(), $service);
         }
         return $types;
     }, 'preferred_choices' => array(), 'empty_data' => function (Options $options) {
         $multiple = isset($options['multiple']) && $options['multiple'];
         $expanded = isset($options['expanded']) && $options['expanded'];
         return $multiple || $expanded ? array() : '';
     }, 'empty_value' => function (Options $options, $previousValue) {
         $multiple = isset($options['multiple']) && $options['multiple'];
         $expanded = isset($options['expanded']) && $options['expanded'];
         return $multiple || $expanded || !isset($previousValue) ? null : '';
     }, 'error_bubbling' => false));
 }
Example #25
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     set_error_handler(array('Symfony\\Component\\Form\\Test\\DeprecationErrorHandler', 'handleBC'));
     $resolver->setDefaults($this->getDefaultOptions(array()));
     $resolver->addAllowedValues($this->getAllowedOptionValues(array()));
     restore_error_handler();
 }
Example #26
0
 /**
  * {@inheritdoc}
  */
 public function configureAttributes(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['name', 'label']);
     $resolver->setOptional(['options', 'comment', 'suffix', 'prefix', 'error', 'selector', 'css_attribute', 'addable', 'onAdd', 'add_item_prompt', 'default', 'property_path', 'dependencies', 'filters', 'rules', 'transformer']);
     $resolver->setDefaults(['options' => [], 'dependencies' => [], 'filters' => [], 'rules' => [], 'property_path' => null, 'transformer' => null]);
     $resolver->setAllowedTypes(['name' => 'string', 'label' => 'string', 'options' => 'array', 'comment' => 'string', 'suffix' => 'string', 'prefix' => 'string', 'error' => 'string', 'selector' => 'string', 'css_attribute' => 'string', 'addable' => 'bool', 'onAdd' => 'string', 'add_item_prompt' => 'string', 'default' => ['string', 'integer'], 'rules' => 'array', 'dependencies' => 'array', 'property_path' => ['null', 'object'], 'transformer' => ['null', 'object']]);
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $that = $this;
     $resolver->setDefaults(array('page' => null, 'site' => null, 'choice_list' => function (Options $opts, $previousValue) use($that) {
         return new SimpleChoiceList($that->getChoices($opts));
     }, 'filter_choice' => array('current_page' => false, 'request_method' => 'GET', 'dynamic' => true, 'hierarchy' => 'all')));
 }
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $self = $this;
     $resolver->setDefaults(array('choice_list' => function (Options $options) use($self) {
         return $self->getChoiceList($options['restrict']);
     }, 'restrict' => array()));
 }
Example #29
0
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $choiceList = function (Options $options) {
         return new ModelChoiceList($options['class'], $options['property'], $options['choices'], $options['query'], $options['group_by'], $options['preferred_choices']);
     };
     $resolver->setDefaults(array('template' => 'choice', 'multiple' => false, 'expanded' => false, 'class' => null, 'property' => null, 'query' => null, 'choices' => null, 'choice_list' => $choiceList, 'group_by' => null, 'by_reference' => false));
 }
Example #30
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $choiceList = function (Options $options) {
         return new VariantChoiceList($options['variable']);
     };
     $resolver->setDefaults(array('multiple' => false, 'expanded' => true, 'choice_list' => $choiceList))->setRequired(array('variable'))->setAllowedTypes(array('variable' => array('Sylius\\Component\\Variation\\Model\\VariableInterface')));
 }