Skip to content

Commit 379cdc7

Browse files
Stop using deprecated method (#762)
1 parent 075b181 commit 379cdc7

9 files changed

+54
-51
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"doctrine/mongodb-odm": "^2.1",
3232
"doctrine/mongodb-odm-bundle": "^4.3",
3333
"doctrine/persistence": "^2.0 || ^3.0",
34-
"sonata-project/admin-bundle": "^4.8",
34+
"sonata-project/admin-bundle": "^4.14",
3535
"sonata-project/form-extensions": "^1.7.1",
3636
"symfony/config": "^4.4 || ^5.4 || ^6.0",
3737
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0",

src/Filter/AbstractDateFilter.php

+6-17
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
namespace Sonata\DoctrineMongoDBAdminBundle\Filter;
1515

1616
use Sonata\AdminBundle\Filter\Model\FilterData;
17-
use Sonata\AdminBundle\Form\Type\Filter\DateRangeType;
18-
use Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType;
19-
use Sonata\AdminBundle\Form\Type\Filter\DateTimeType;
20-
use Sonata\AdminBundle\Form\Type\Filter\DateType;
2117
use Sonata\AdminBundle\Form\Type\Operator\DateOperatorType;
2218
use Sonata\AdminBundle\Form\Type\Operator\DateRangeOperatorType;
2319
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
@@ -45,23 +41,16 @@ final public function getDefaultOptions(): array
4541
];
4642
}
4743

48-
final public function getRenderSettings(): array
44+
/**
45+
* @return array<string, mixed>
46+
*/
47+
final public function getFormOptions(): array
4948
{
50-
$name = DateType::class;
51-
52-
if ($this->time && $this->range) {
53-
$name = DateTimeRangeType::class;
54-
} elseif ($this->time) {
55-
$name = DateTimeType::class;
56-
} elseif ($this->range) {
57-
$name = DateRangeType::class;
58-
}
59-
60-
return [$name, [
49+
return [
6150
'field_type' => $this->getFieldType(),
6251
'field_options' => $this->getFieldOptions(),
6352
'label' => $this->getLabel(),
64-
]];
53+
];
6554
}
6655

6756
/**

src/Filter/BooleanFilter.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace Sonata\DoctrineMongoDBAdminBundle\Filter;
1515

1616
use Sonata\AdminBundle\Filter\Model\FilterData;
17-
use Sonata\AdminBundle\Form\Type\Filter\DefaultType;
1817
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
1918
use Sonata\Form\Type\BooleanType;
2019
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -30,15 +29,18 @@ public function getDefaultOptions(): array
3029
];
3130
}
3231

33-
public function getRenderSettings(): array
32+
/**
33+
* @return array<string, mixed>
34+
*/
35+
public function getFormOptions(): array
3436
{
35-
return [DefaultType::class, [
37+
return [
3638
'field_type' => $this->getFieldType(),
3739
'field_options' => $this->getFieldOptions(),
3840
'operator_type' => $this->getOption('operator_type'),
3941
'operator_options' => $this->getOption('operator_options'),
4042
'label' => $this->getLabel(),
41-
]];
43+
];
4244
}
4345

4446
protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void

src/Filter/CallbackFilter.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace Sonata\DoctrineMongoDBAdminBundle\Filter;
1515

1616
use Sonata\AdminBundle\Filter\Model\FilterData;
17-
use Sonata\AdminBundle\Form\Type\Filter\DefaultType;
1817
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
1918
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
2019
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -31,15 +30,18 @@ public function getDefaultOptions(): array
3130
];
3231
}
3332

34-
public function getRenderSettings(): array
33+
/**
34+
* @return array<string, mixed>
35+
*/
36+
public function getFormOptions(): array
3537
{
36-
return [DefaultType::class, [
37-
'field_type' => $this->getFieldType(),
38-
'field_options' => $this->getFieldOptions(),
39-
'operator_type' => $this->getOption('operator_type'),
40-
'operator_options' => $this->getOption('operator_options'),
41-
'label' => $this->getLabel(),
42-
]];
38+
return [
39+
'field_type' => $this->getFieldType(),
40+
'field_options' => $this->getFieldOptions(),
41+
'operator_type' => $this->getOption('operator_type'),
42+
'operator_options' => $this->getOption('operator_options'),
43+
'label' => $this->getLabel(),
44+
];
4345
}
4446

4547
protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void

src/Filter/ChoiceFilter.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace Sonata\DoctrineMongoDBAdminBundle\Filter;
1515

1616
use Sonata\AdminBundle\Filter\Model\FilterData;
17-
use Sonata\AdminBundle\Form\Type\Filter\DefaultType;
1817
use Sonata\AdminBundle\Form\Type\Operator\ContainsOperatorType;
1918
use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType;
2019
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
@@ -29,15 +28,18 @@ public function getDefaultOptions(): array
2928
];
3029
}
3130

32-
public function getRenderSettings(): array
31+
/**
32+
* @return array<string, mixed>
33+
*/
34+
public function getFormOptions(): array
3335
{
34-
return [DefaultType::class, [
36+
return [
3537
'operator_type' => $this->getOption('operator_type'),
3638
'operator_options' => $this->getOption('operator_options'),
3739
'field_type' => $this->getFieldType(),
3840
'field_options' => $this->getFieldOptions(),
3941
'label' => $this->getLabel(),
40-
]];
42+
];
4143
}
4244

4345
protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void

src/Filter/IdFilter.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use MongoDB\BSON\ObjectId;
1717
use MongoDB\Driver\Exception\InvalidArgumentException;
1818
use Sonata\AdminBundle\Filter\Model\FilterData;
19-
use Sonata\AdminBundle\Form\Type\Filter\DefaultType;
2019
use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType;
2120
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
2221
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -31,14 +30,17 @@ public function getDefaultOptions(): array
3130
];
3231
}
3332

34-
public function getRenderSettings(): array
33+
/**
34+
* @return array<string, mixed>
35+
*/
36+
public function getFormOptions(): array
3537
{
36-
return [DefaultType::class, [
38+
return [
3739
'field_type' => $this->getFieldType(),
3840
'field_options' => $this->getFieldOptions(),
3941
'operator_type' => $this->getOption('operator_type'),
4042
'label' => $this->getLabel(),
41-
]];
43+
];
4244
}
4345

4446
protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void

src/Filter/ModelFilter.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use MongoDB\BSON\ObjectId;
2020
use MongoDB\Driver\Exception\InvalidArgumentException;
2121
use Sonata\AdminBundle\Filter\Model\FilterData;
22-
use Sonata\AdminBundle\Form\Type\Filter\DefaultType;
2322
use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType;
2423
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
2524

@@ -36,15 +35,18 @@ public function getDefaultOptions(): array
3635
];
3736
}
3837

39-
public function getRenderSettings(): array
38+
/**
39+
* @return array<string, mixed>
40+
*/
41+
public function getFormOptions(): array
4042
{
41-
return [DefaultType::class, [
43+
return [
4244
'field_type' => $this->getFieldType(),
4345
'field_options' => $this->getFieldOptions(),
4446
'operator_type' => $this->getOption('operator_type'),
4547
'operator_options' => $this->getOption('operator_options'),
4648
'label' => $this->getLabel(),
47-
]];
49+
];
4850
}
4951

5052
protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void

src/Filter/NumberFilter.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace Sonata\DoctrineMongoDBAdminBundle\Filter;
1515

1616
use Sonata\AdminBundle\Filter\Model\FilterData;
17-
use Sonata\AdminBundle\Form\Type\Filter\NumberType;
1817
use Sonata\AdminBundle\Form\Type\Operator\NumberOperatorType;
1918
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
2019
use Symfony\Component\Form\Extension\Core\Type\NumberType as SymfonyNumberType;
@@ -34,13 +33,16 @@ public function getDefaultOptions(): array
3433
return ['field_type' => SymfonyNumberType::class];
3534
}
3635

37-
public function getRenderSettings(): array
36+
/**
37+
* @return array<string, mixed>
38+
*/
39+
public function getFormOptions(): array
3840
{
39-
return [NumberType::class, [
41+
return [
4042
'field_type' => $this->getFieldType(),
4143
'field_options' => $this->getFieldOptions(),
4244
'label' => $this->getLabel(),
43-
]];
45+
];
4446
}
4547

4648
protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void

src/Filter/StringFilter.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Doctrine\ODM\MongoDB\Query\Expr;
1717
use MongoDB\BSON\Regex;
1818
use Sonata\AdminBundle\Filter\Model\FilterData;
19-
use Sonata\AdminBundle\Form\Type\Filter\ChoiceType;
2019
use Sonata\AdminBundle\Form\Type\Operator\ContainsOperatorType;
2120
use Sonata\AdminBundle\Search\SearchableFilterInterface;
2221
use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface;
@@ -32,13 +31,16 @@ public function getDefaultOptions(): array
3231
];
3332
}
3433

35-
public function getRenderSettings(): array
34+
/**
35+
* @return array<string, mixed>
36+
*/
37+
public function getFormOptions(): array
3638
{
37-
return [ChoiceType::class, [
39+
return [
3840
'field_type' => $this->getFieldType(),
3941
'field_options' => $this->getFieldOptions(),
4042
'label' => $this->getLabel(),
41-
]];
43+
];
4244
}
4345

4446
public function isSearchEnabled(): bool

0 commit comments

Comments
 (0)