Skip to content

Commit

Permalink
Improved support for symfony3 (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 authored and OskarStark committed Aug 16, 2016
1 parent 9d3d464 commit b6d9a60
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 8 deletions.
11 changes: 11 additions & 0 deletions Filter/AbstractDateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ public function getRenderSettings()
$name .= '_range';
}

// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) {
$classnames = array(
'sonata_type_filter_date' => 'Sonata\AdminBundle\Form\Type\Filter\DateType',
'sonata_type_filter_date_range' => 'Sonata\AdminBundle\Form\Type\Filter\DateRangeType',
'sonata_type_filter_datetime' => 'Sonata\AdminBundle\Form\Type\Filter\DateTimeType',
'sonata_type_filter_datetime_range' => 'Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType',
);
$name = $classnames[$name];
}

return array($name, array(
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
Expand Down
7 changes: 6 additions & 1 deletion Filter/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ public function getDefaultOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\DefaultType'
: 'sonata_type_filter_default';

return array($type, array(
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'operator_type' => 'hidden',
Expand Down
7 changes: 6 additions & 1 deletion Filter/CallbackFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public function getDefaultOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\DefaultType'
: 'sonata_type_filter_default';

return array($type, array(
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'operator_type' => $this->getOption('operator_type'),
Expand Down
7 changes: 6 additions & 1 deletion Filter/ChoiceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ public function getDefaultOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\DefaultType'
: 'sonata_type_filter_default';

return array($type, array(
'operator_type' => 'sonata_type_equal',
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
Expand Down
7 changes: 6 additions & 1 deletion Filter/ClassFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ public function getFieldOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\DefaultType'
: 'sonata_type_filter_default';

return array($type, array(
'operator_type' => 'sonata_type_equal',
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
Expand Down
7 changes: 6 additions & 1 deletion Filter/ModelAutocompleteFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public function getDefaultOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\DefaultType'
: 'sonata_type_filter_default';

return array($type, array(
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'operator_type' => $this->getOption('operator_type'),
Expand Down
7 changes: 6 additions & 1 deletion Filter/ModelFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ public function getDefaultOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_default', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\DefaultType'
: 'sonata_type_filter_default';

return array($type, array(
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'operator_type' => $this->getOption('operator_type'),
Expand Down
7 changes: 6 additions & 1 deletion Filter/NumberFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public function getDefaultOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_number', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\NumberType'
: 'sonata_type_filter_number';

return array($type, array(
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'label' => $this->getLabel(),
Expand Down
7 changes: 6 additions & 1 deletion Filter/StringFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ public function getDefaultOptions()
*/
public function getRenderSettings()
{
return array('sonata_type_filter_choice', array(
// NEXT_MAJOR: Remove this line when drop Symfony <2.8 support
$type = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Sonata\AdminBundle\Form\Type\Filter\ChoiceType'
: 'sonata_type_filter_choice';

return array($type, array(
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'label' => $this->getLabel(),
Expand Down

0 comments on commit b6d9a60

Please sign in to comment.