public function createToDate($dateEnd = "now", $date_format = null, $date_interval = null)
 {
     $date_format = $date_format ? $date_format : $this->date_format;
     $date_interval = $date_interval ? $date_interval : $this->default_interval;
     $dateRange = new DateRange($date_format);
     if ($dateEnd == "now") {
         $dateEnd = new \DateTime();
     }
     $dateRange->createToDate($dateEnd, $date_interval);
     return $dateRange;
 }
 public function reverseTransform($value)
 {
     if ('' === $value || null === $value) {
         return null;
     }
     if (!is_string($value)) {
         return null;
     }
     $dateRange = new DateRange($this->date_format, $this->daterange_separator);
     $dateRange->parseData($value);
     return $dateRange;
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (!isset($options['default'])) {
         if ($options['required']) {
             $dateRange = new DateRange($this->date_format);
             $dateRange->createToDate(new \DateTime(), $this->default_interval);
         } else {
             $dateRange = null;
         }
     } else {
         $dateRange = $options['default'];
     }
     $options['default'] = $dateRange;
     $builder->appendClientTransformer(new DateRangeToValueTransformer($this->date_format));
     $builder->setData($options['default']);
     // Datepicker date format
     $searches = array('d', 'm', 'y', 'Y');
     $replaces = array('dd', 'mm', 'yy', 'yyyy');
     $datepicker_format = str_replace($searches, $replaces, $this->date_format);
     $builder->setAttribute('datepicker_date_format', $datepicker_format);
 }