Example #1
1
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $transformer = new ManyRelatedTransformer($this->doctrineRegistry, $options['entityName']);
     $viewTransformer = new ArrayToStringTransformer();
     $builder->addModelTransformer($transformer);
     $builder->addViewTransformer($viewTransformer);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addViewTransformer($this->createEntitiesToIdsTransformer($options));
     if ($options['multiple']) {
         $builder->addViewTransformer(new ArrayToStringTransformer($options['values_delimiter'], true))->addEventSubscriber(new FixArrayToStringListener($options['values_delimiter']));
     }
 }
Example #3
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (isset($options['transformer'])) {
         $builder->addViewTransformer(new $options['transformer']());
     } else {
         $builder->addViewTransformer(new IdentifiableToUriTransformer($options['class'], $options['dsl_client']));
     }
 }
Example #4
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // @todo I could combine the transformers below into a single class...
     if ($options['multiple']) {
         $builder->addViewTransformer(new EntitiesToPropertyTransformer($options['em'] ?: $this->em, $options['class'], $options['property']), true);
     } else {
         $builder->addViewTransformer(new EntityToPropertyTransformer($options['em'] ?: $this->em, $options['class'], $options['property']), true);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['choice_data'] == 'scalar') {
         if ($options['multiple']) {
             $builder->addViewTransformer(new ValuesToChoicesTransformer($options['choice_list']), true);
         } else {
             $builder->addViewTransformer(new ValueToChoiceTransformer($options['choice_list']), true);
         }
     }
 }
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->resetViewTransformers();
     $builder->addViewTransformer(new ObjectToIdTransformer($this->em, $options['class']));
     if ($options['multiple']) {
         $builder->addViewTransformer(new EntityArrayToIdArrayTransformer($this->em, null));
     } else {
         $builder->addViewTransformer(new ArrayToIdTransformer($this->em, null));
     }
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $parts = array('hour', 'minute');
     $format = 'H:i';
     if ($options['with_seconds']) {
         $format = 'H:i:s';
         $parts[] = 'second';
     }
     if ('single_text' === $options['widget']) {
         $builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
     } else {
         $hourOptions = $minuteOptions = $secondOptions = array('error_bubbling' => true);
         if ('choice' === $options['widget']) {
             $hours = $minutes = array();
             foreach ($options['hours'] as $hour) {
                 $hours[$hour] = str_pad($hour, 2, '0', STR_PAD_LEFT);
             }
             foreach ($options['minutes'] as $minute) {
                 $minutes[$minute] = str_pad($minute, 2, '0', STR_PAD_LEFT);
             }
             // Only pass a subset of the options to children
             $hourOptions['choices'] = $hours;
             $hourOptions['empty_value'] = $options['empty_value']['hour'];
             $minuteOptions['choices'] = $minutes;
             $minuteOptions['empty_value'] = $options['empty_value']['minute'];
             if ($options['with_seconds']) {
                 $seconds = array();
                 foreach ($options['seconds'] as $second) {
                     $seconds[$second] = str_pad($second, 2, '0', STR_PAD_LEFT);
                 }
                 $secondOptions['choices'] = $seconds;
                 $secondOptions['empty_value'] = $options['empty_value']['second'];
             }
             // Append generic carry-along options
             foreach (array('required', 'translation_domain') as $passOpt) {
                 $hourOptions[$passOpt] = $minuteOptions[$passOpt] = $options[$passOpt];
                 if ($options['with_seconds']) {
                     $secondOptions[$passOpt] = $options[$passOpt];
                 }
             }
         }
         $builder->add('hour', $options['widget'], $hourOptions)->add('minute', $options['widget'], $minuteOptions);
         if ($options['with_seconds']) {
             $builder->add('second', $options['widget'], $secondOptions);
         }
         $builder->addViewTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts, 'text' === $options['widget']));
     }
     if ('string' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'H:i:s')));
     } elseif ('timestamp' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone'])));
     } elseif ('array' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], $parts)));
     }
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $parts = array('year', 'month', 'day', 'hour');
     $dateParts = array('year', 'month', 'day');
     $timeParts = array('hour');
     if ($options['with_minutes']) {
         $parts[] = 'minute';
         $timeParts[] = 'minute';
     }
     if ($options['with_seconds']) {
         $parts[] = 'second';
         $timeParts[] = 'second';
     }
     $dateFormat = is_int($options['date_format']) ? $options['date_format'] : self::DEFAULT_DATE_FORMAT;
     $timeFormat = self::DEFAULT_TIME_FORMAT;
     $calendar = \IntlDateFormatter::GREGORIAN;
     $pattern = is_string($options['format']) ? $options['format'] : null;
     if (!in_array($dateFormat, self::$acceptedFormats, true)) {
         throw new InvalidOptionsException('The "date_format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.');
     }
     if ('single_text' === $options['widget']) {
         if (self::HTML5_FORMAT === $pattern) {
             $builder->addViewTransformer(new DateTimeToRfc3339Transformer($options['model_timezone'], $options['view_timezone']));
         } else {
             $builder->addViewTransformer(new DateTimeToLocalizedStringTransformer($options['model_timezone'], $options['view_timezone'], $dateFormat, $timeFormat, $calendar, $pattern));
         }
     } else {
         // Only pass a subset of the options to children
         $dateOptions = array_intersect_key($options, array_flip(array('years', 'months', 'days', 'empty_value', 'placeholder', 'required', 'translation_domain', 'html5', 'invalid_message', 'invalid_message_parameters')));
         $timeOptions = array_intersect_key($options, array_flip(array('hours', 'minutes', 'seconds', 'with_minutes', 'with_seconds', 'empty_value', 'placeholder', 'required', 'translation_domain', 'html5', 'invalid_message', 'invalid_message_parameters')));
         if (null !== $options['date_widget']) {
             $dateOptions['widget'] = $options['date_widget'];
         }
         if (null !== $options['time_widget']) {
             $timeOptions['widget'] = $options['time_widget'];
         }
         if (null !== $options['date_format']) {
             $dateOptions['format'] = $options['date_format'];
         }
         $dateOptions['input'] = $timeOptions['input'] = 'array';
         $dateOptions['error_bubbling'] = $timeOptions['error_bubbling'] = true;
         $builder->addViewTransformer(new DataTransformerChain(array(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts), new ArrayToPartsTransformer(array('date' => $dateParts, 'time' => $timeParts)))))->add('date', 'date', $dateOptions)->add('time', 'time', $timeOptions);
     }
     if ('string' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'])));
     } elseif ('timestamp' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone'])));
     } elseif ('array' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], $parts)));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['multiple']) {
         if (array_key_exists('choice_loader', $options) && $options['choice_loader'] !== null) {
             // SF2.7+
             $builder->addViewTransformer(new ModelsToArrayTransformer($options['choice_loader'], $options['model_manager'], $options['class']), true);
         } else {
             $builder->addViewTransformer(new LegacyModelsToArrayTransformer($options['choice_list']), true);
         }
         $builder->addEventSubscriber(new MergeCollectionListener($options['model_manager']));
     } else {
         $builder->addViewTransformer(new ModelToIdTransformer($options['model_manager'], $options['class']), true);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // Overwrite required option for child fields
     $options['first_options']['required'] = $options['required'];
     $options['second_options']['required'] = $options['required'];
     $builder->addViewTransformer(new ValueToDuplicatesTransformer(array($options['first_name'], $options['second_name'])))->add($options['first_name'], $options['type'], array_merge($options['options'], $options['first_options']))->add($options['second_name'], $options['type'], array_merge($options['options'], $options['second_options']));
 }
Example #11
0
 /**
  * @inheritdoc
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber($this->subscriber);
     $builder->addViewTransformer(new ResourceTransformer());
     $builder->add('file', 'file');
     $builder->add('delete', 'checkbox', ['required' => false]);
 }
 function it_builds_form(FormBuilderInterface $builder, IdentifiableObjectRepositoryInterface $repository, DataTransformerInterface $transformer, $transformerFactory)
 {
     $options = ['repository' => $repository->getWrappedObject(), 'multiple' => false];
     $transformerFactory->create($repository, ['multiple' => false])->willReturn($transformer);
     $builder->addViewTransformer($transformer, true)->shouldBeCalled();
     $this->buildForm($builder, $options);
 }
Example #13
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     foreach ($this->fields as $field) {
         list($name, $type, $options) = $field;
         $builder->add($name, $type, $options);
     }
     $class = $this->class;
     foreach ($this->eventListeners as $eventListener) {
         list($method, $event, $priority) = $eventListener;
         $builder->addEventListener($event, function (FormEvent $event) use($builder, $class, $method) {
             $data = $builder->getData();
             if (!$data instanceof $class) {
                 $data = $event->getData();
                 if (!$data instanceof $class) {
                     return;
                 }
             }
             if (!method_exists($data, $method)) {
                 return;
             }
             $data->{$method}($event);
         }, $priority);
     }
     foreach ($this->eventSubscribers as $eventSubscriber) {
         $builder->addEventSubscriber($eventSubscriber);
     }
     foreach ($this->modelTransformers as $modelTransformer) {
         $builder->addModelTransformer($modelTransformer);
     }
     foreach ($this->viewTransformers as $viewTransformer) {
         $builder->addViewTransformer($viewTransformer);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('years', 'choice', array('choices' => range(0, $options['nb_years_choices'], 1)))->add('months', 'choice', array('choices' => range(0, 11, 1)))->add('days', 'choice', array('choices' => range(0, 30, 1)));
     if ($options['with_hours']) {
         $builder->add('hours', 'choice', array('choices' => range(0, 23, 1)));
     }
     if ($options['with_minutes']) {
         $builder->add('minutes', 'choice', array('choices' => range(0, 59, 1)));
     }
     if ($options['with_seconds']) {
         $builder->add('seconds', 'choice', array('choices' => range(0, 59, 1)));
     }
     //Transform to \DateInterval & reverse
     $builder->addViewTransformer(new CallbackTransformer(function (\DateInterval $value = null) {
         if ($value === null) {
             return null;
         }
         return array('seconds' => $value->s, 'minutes' => $value->i, 'hours' => $value->h, 'days' => $value->d, 'months' => $value->m, 'years' => $value->y);
     }, function ($value) {
         if ($value === null) {
             return null;
         }
         $interval = new \DateInterval('PT0S');
         $interval->s = isset($value['seconds']) ? $value['seconds'] : 0;
         $interval->i = isset($value['minutes']) ? $value['minutes'] : 0;
         $interval->h = isset($value['hours']) ? $value['hours'] : 0;
         $interval->d = isset($value['days']) ? $value['days'] : 0;
         $interval->m = isset($value['months']) ? $value['months'] : 0;
         $interval->y = isset($value['years']) ? $value['years'] : 0;
         //If no interval, return null
         $now = new \DateTime();
         $copy = clone $now;
         return $now->getTimestamp() === $copy->add($interval)->getTimestamp() ? null : $interval;
     }));
 }
Example #15
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (null === $options['class']) {
         throw new InvalidConfigurationException('Option "class" is empty');
     }
     if (null === $options['parent_field']) {
         throw new InvalidConfigurationException('Option "parent_field" is empty');
     }
     if (null === $options['property']) {
         throw new InvalidConfigurationException('Option "property" is empty');
     }
     $builder->addViewTransformer(new EntityToIdTransformer($this->em, $options['class']), true);
     $query = $options['query'];
     if ($query instanceof \Closure) {
         $queryBuilder = $query($this->em->getRepository($options['class']));
         $query = $queryBuilder->getQuery()->getDql();
     }
     $builder->setAttribute('class', $options['class']);
     $builder->setAttribute("parent_field", $options['parent_field']);
     $builder->setAttribute("no_result_msg", $options['no_result_msg']);
     $builder->setAttribute("empty_value", $options['empty_value']);
     $builder->setAttribute("property", $options['property']);
     $builder->setAttribute("em_name", $options['em_name']);
     $builder->setAttribute('query', $query);
     $builder->setAttribute("order_direction", $options['order_direction']);
     $builder->setAttribute("order_property", $options['order_property']);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $formType = $options['type'];
     $formOptions = $options['options'];
     $builder->add(self::FIELD_DEFAULT, $formType, array_merge($formOptions, ['label' => 'orob2b.fallback.value.default']))->add(self::FIELD_LOCALES, LocaleCollectionType::NAME, ['type' => $formType, 'options' => $formOptions]);
     $builder->addViewTransformer(new MultipleValueTransformer(self::FIELD_DEFAULT, self::FIELD_LOCALES));
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $format = $options['format'];
     $pattern = null;
     $allowedFormatOptionValues = array(\IntlDateFormatter::FULL, \IntlDateFormatter::LONG, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT);
     // If $format is not in the allowed options, it's considered as the pattern of the formatter if it is a string
     if (!in_array($format, $allowedFormatOptionValues, true)) {
         if (is_string($format)) {
             $format = self::DEFAULT_FORMAT;
             $pattern = $options['format'];
         } else {
             throw new CreationException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom pattern');
         }
     }
     $formatter = new \IntlDateFormatter(\Locale::getDefault(), $format, \IntlDateFormatter::NONE, 'UTC', \IntlDateFormatter::GREGORIAN, $pattern);
     $formatter->setLenient(false);
     $builder->addViewTransformer(new DateTimeToLocalizedStringTransformer($options['data_timezone'], $options['user_timezone'], $format, \IntlDateFormatter::NONE, \IntlDateFormatter::GREGORIAN, $pattern));
     if ('string' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'], 'Y-m-d')));
     } elseif ('timestamp' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToTimestampTransformer($options['data_timezone'], $options['data_timezone'])));
     } elseif ('array' === $options['input']) {
         $builder->addModelTransformer(new ReversedTransformer(new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], array('year', 'month', 'day'))));
     }
     $builder->setAttribute('date_pattern', $formatter->getPattern());
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addViewTransformer(new ArrayToStringTransformer($options['separator'], array('from', 'to')));
     if ($options['use_daterange_entity']) {
         $builder->addModelTransformer(new DateRangeToArrayTransformer($options['format']));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (self::WIDGET_COUNTRY_CHOICE === $options['widget']) {
         $util = PhoneNumberUtil::getInstance();
         $countries = array();
         if (is_array($options['country_choices'])) {
             foreach ($options['country_choices'] as $country) {
                 $code = $util->getCountryCodeForRegion($country);
                 if ($code) {
                     $countries[$country] = $code;
                 }
             }
         }
         if (empty($countries)) {
             foreach ($util->getSupportedRegions() as $country) {
                 $countries[$country] = $util->getCountryCodeForRegion($country);
             }
         }
         $countryChoices = array();
         foreach (Intl::getRegionBundle()->getCountryNames() as $region => $name) {
             if (false === isset($countries[$region])) {
                 continue;
             }
             $countryChoices[$region] = sprintf('%s (+%s)', $name, $countries[$region]);
         }
         $countryOptions = $numberOptions = array('error_bubbling' => true, 'required' => $options['required'], 'disabled' => $options['disabled'], 'translation_domain' => $options['translation_domain']);
         $countryOptions['required'] = true;
         $countryOptions['choices'] = $countryChoices;
         $countryOptions['preferred_choices'] = $options['preferred_country_choices'];
         $countryOptions['choice_translation_domain'] = false;
         $builder->add('country', 'choice', $countryOptions)->add('number', 'text', $numberOptions)->addViewTransformer(new PhoneNumberToArrayTransformer(array_keys($countryChoices)));
     } else {
         $builder->addViewTransformer(new PhoneNumberToStringTransformer($options['default_region'], $options['format']));
     }
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // add custom data transformer
     if ($options['transformer']) {
         if (!is_string($options['transformer'])) {
             throw new \Exception('The option transformer must be a string');
         }
         if (!class_exists($options['transformer'])) {
             throw new \Exception('Unable to load class: ' . $options['transformer']);
         }
         $transformer = new $options['transformer']($this->em, $options['class']);
         if (!$transformer instanceof DataTransformerInterface) {
             throw new \Exception(sprintf('The custom transformer %s must implement "Symfony\\Component\\Form\\DataTransformerInterface"', get_class($transformer)));
         }
         // add the default data transformer
     } else {
         if (isset($options['allow_add']['new_tag_prefix'])) {
             $newTagPrefix = $options['allow_add']['new_tag_prefix'];
         } else {
             $newTagPrefix = $this->config['allow_add']['new_tag_prefix'];
         }
         $transformer = $options['multiple'] ? new EntitiesToPropertyTransformer($this->em, $options['class'], $options['text_property'], $options['primary_key'], $newTagPrefix) : new EntityToPropertyTransformer($this->em, $options['class'], $options['text_property'], $options['primary_key']);
     }
     $builder->addViewTransformer($transformer, true);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addViewTransformer(new ModelToIdTransformer($options['model_manager'], $options['class']), true);
     $builder->setAttribute('root_node', $options['root_node']);
     $builder->setAttribute('select_root_node', $options['select_root_node']);
     $builder->setAttribute('repository_name', $options['repository_name']);
 }
Example #22
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['mapped']) {
         $prototype = $builder->create('__id__', 'opifer_media_edit', array_replace(['label' => '__id__label__'], []));
         $builder->setAttribute('prototype', $prototype->getForm());
     }
     $builder->addViewTransformer(new CollectionToStringTransformer($this->mediaManager));
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!$options['select2']['enabled'] || $options['multiple'] || !$options['select2']['tags']) {
         return;
     }
     $builder->resetViewTransformers();
     $builder->addViewTransformer(new Select2ChoiceToValueTransformer($options['choice_loader']));
 }
Example #24
0
 /**
  * @since 2.4 flip keys and values and add choices_as_values option
  * @param  FormBuilderInterface $builder [description]
  * @param  array                $options [description]
  * @return [type]               [description]
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // Ajout d'un champ de saisi manuel si voulu
     $options['choices']['Other amount'] = 'manual';
     $builder->addViewTransformer(new AmountChoiceToIntentAmountTransformer(['manual', 'preselected']))->add('preselected', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType', ['choices' => $options['choices'], 'required' => false, 'expanded' => true, 'multiple' => false, 'label' => false, 'data' => $options['default'], 'choices_as_values' => true, 'choice_value' => function ($choice) {
         return $choice;
     }])->add('manual', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\MoneyType', ['currency' => 'EUR', 'required' => false, 'label' => 'Another amount', 'scale' => 0, 'constraints' => [new Assert\Range(['min' => $options['min_amount'], 'max' => $options['max_amount'], 'minMessage' => $this->translator->trans('Amount must be greater than %amount% €', ['%amount%' => $options['min_amount']], 'validation'), 'maxMessage' => $this->translator->trans('Amount must be lower than  %amount% €', ['%amount%' => $options['max_amount']], 'validation')])]]);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $repository = $options['repository'];
     if (!$repository instanceof IdentifiableObjectRepositoryInterface) {
         throw new UnexpectedTypeException($repository, '\\Akeneo\\Component\\StorageUtils\\Repository\\IdentifiableObjectRepositoryInterface');
     }
     $builder->addViewTransformer($this->createDataTransformer($repository, $options), true);
 }
Example #26
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $alias = $options['alias'];
     if (false == isset($this->config[$alias])) {
         throw new \Exception(sprintf('No config found for autocomplete alias: %s'), $alias);
     }
     $builder->addViewTransformer(new PropertyToEntityTransformer($this->em, $this->config[$alias]), true);
 }
Example #27
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ($options['multiple']) {
         $builder->addEventSubscriber(new MergeCollectionListener($options['model_manager']))->addViewTransformer(new ModelsToArrayTransformer($options['choice_list']), true);
     } else {
         $builder->addViewTransformer(new ModelToIdTransformer($options['model_manager'], $options['class']), true);
     }
 }
 /**
  * @inheritdoc
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $tags = false;
     if (isset($options['configs']['tags'])) {
         $tags = $options['configs']['tags'];
     }
     $builder->addViewTransformer($options['multiple'] ? new EntitiesToPropertyTransformer($this->em, $tags, $options['class'], $options['property']) : new EntityToPropertyTransformer($this->em, $tags, $options['class'], $options['property']));
 }
Example #29
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if ('hidden' === $this->widget && !empty($options['configs']['multiple'])) {
         $builder->addViewTransformer(new ArrayToStringTransformer());
     } elseif ('hidden' === $this->widget && empty($options['configs']['multiple']) && null !== $options['transformer']) {
         $builder->addModelTransformer($options['transformer']);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $dateFormat = is_int($options['date_format']) ? $options['date_format'] : self::DEFAULT_DATE_FORMAT;
     $timeFormat = is_int($options['time_format']) ? $options['time_format'] : self::DEFAULT_TIME_FORMAT;
     if (!in_array($dateFormat, self::$acceptedFormats, true)) {
         throw new InvalidOptionsException('The "date_format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.');
     }
     $builder->addViewTransformer(new DateTimeSplitterTransformer($options['data_timezone'], $options['user_timezone'], $dateFormat, $timeFormat, \IntlDateFormatter::GREGORIAN))->add('date', 'rmzamora_custom_datepicker', array('input' => 'string', 'datepicker_type' => 'datetimepicker', 'required' => false, 'format' => $options['date_default_format'], 'datepicker_format' => $options['datepicker_format'], 'datepicker_start_date' => $options['datepicker_start_date'], 'datepicker_end_date' => $options['datepicker_end_date'], 'datepicker_show_on' => $options['datepicker_show_on'], 'datepicker_autoclose' => $options['datepicker_autoclose'], 'datepicker_start_view' => $options['datepicker_start_view'], 'datepicker_week_start' => $options['datepicker_week_start']))->add('time', 'rmzamora_custom_timepicker', array('input' => 'string', 'timepicker_type' => 'datetimepicker', 'required' => false, 'format' => 'H:i:s', 'timepicker_template' => $options['timepicker_template'], 'timepicker_minute_step' => $options['timepicker_minute_step'], 'timepicker_second_step' => $options['timepicker_second_step'], 'timepicker_show_seconds' => $options['timepicker_show_seconds'], 'timepicker_default_time' => $options['timepicker_default_time'], 'timepicker_disable_focus' => $options['timepicker_disable_focus'], 'timepicker_modal_backdrop' => $options['timepicker_modal_backdrop']));
 }