From 379cdc790213340db1bf7e49f5cea8fd8e86b1ee Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 12 Jul 2022 22:27:56 +0200 Subject: [PATCH] Stop using deprecated method (#762) --- composer.json | 2 +- src/Filter/AbstractDateFilter.php | 23 ++++++----------------- src/Filter/BooleanFilter.php | 10 ++++++---- src/Filter/CallbackFilter.php | 20 +++++++++++--------- src/Filter/ChoiceFilter.php | 10 ++++++---- src/Filter/IdFilter.php | 10 ++++++---- src/Filter/ModelFilter.php | 10 ++++++---- src/Filter/NumberFilter.php | 10 ++++++---- src/Filter/StringFilter.php | 10 ++++++---- 9 files changed, 54 insertions(+), 51 deletions(-) diff --git a/composer.json b/composer.json index f33e516f..c0c899ce 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "doctrine/mongodb-odm": "^2.1", "doctrine/mongodb-odm-bundle": "^4.3", "doctrine/persistence": "^2.0 || ^3.0", - "sonata-project/admin-bundle": "^4.8", + "sonata-project/admin-bundle": "^4.14", "sonata-project/form-extensions": "^1.7.1", "symfony/config": "^4.4 || ^5.4 || ^6.0", "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0", diff --git a/src/Filter/AbstractDateFilter.php b/src/Filter/AbstractDateFilter.php index 5280cf7d..2c55badc 100644 --- a/src/Filter/AbstractDateFilter.php +++ b/src/Filter/AbstractDateFilter.php @@ -14,10 +14,6 @@ namespace Sonata\DoctrineMongoDBAdminBundle\Filter; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\DateRangeType; -use Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType; -use Sonata\AdminBundle\Form\Type\Filter\DateTimeType; -use Sonata\AdminBundle\Form\Type\Filter\DateType; use Sonata\AdminBundle\Form\Type\Operator\DateOperatorType; use Sonata\AdminBundle\Form\Type\Operator\DateRangeOperatorType; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; @@ -45,23 +41,16 @@ final public function getDefaultOptions(): array ]; } - final public function getRenderSettings(): array + /** + * @return array + */ + final public function getFormOptions(): array { - $name = DateType::class; - - if ($this->time && $this->range) { - $name = DateTimeRangeType::class; - } elseif ($this->time) { - $name = DateTimeType::class; - } elseif ($this->range) { - $name = DateRangeType::class; - } - - return [$name, [ + return [ 'field_type' => $this->getFieldType(), 'field_options' => $this->getFieldOptions(), 'label' => $this->getLabel(), - ]]; + ]; } /** diff --git a/src/Filter/BooleanFilter.php b/src/Filter/BooleanFilter.php index 74f75a22..7eb10dff 100644 --- a/src/Filter/BooleanFilter.php +++ b/src/Filter/BooleanFilter.php @@ -14,7 +14,6 @@ namespace Sonata\DoctrineMongoDBAdminBundle\Filter; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; use Sonata\Form\Type\BooleanType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -30,15 +29,18 @@ public function getDefaultOptions(): array ]; } - public function getRenderSettings(): array + /** + * @return array + */ + public function getFormOptions(): array { - return [DefaultType::class, [ + return [ 'field_type' => $this->getFieldType(), 'field_options' => $this->getFieldOptions(), 'operator_type' => $this->getOption('operator_type'), 'operator_options' => $this->getOption('operator_options'), 'label' => $this->getLabel(), - ]]; + ]; } protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void diff --git a/src/Filter/CallbackFilter.php b/src/Filter/CallbackFilter.php index 26730189..0cba8b20 100644 --- a/src/Filter/CallbackFilter.php +++ b/src/Filter/CallbackFilter.php @@ -14,7 +14,6 @@ namespace Sonata\DoctrineMongoDBAdminBundle\Filter; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -31,15 +30,18 @@ public function getDefaultOptions(): array ]; } - public function getRenderSettings(): array + /** + * @return array + */ + public function getFormOptions(): array { - return [DefaultType::class, [ - 'field_type' => $this->getFieldType(), - 'field_options' => $this->getFieldOptions(), - 'operator_type' => $this->getOption('operator_type'), - 'operator_options' => $this->getOption('operator_options'), - 'label' => $this->getLabel(), - ]]; + return [ + 'field_type' => $this->getFieldType(), + 'field_options' => $this->getFieldOptions(), + 'operator_type' => $this->getOption('operator_type'), + 'operator_options' => $this->getOption('operator_options'), + 'label' => $this->getLabel(), + ]; } protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void diff --git a/src/Filter/ChoiceFilter.php b/src/Filter/ChoiceFilter.php index 941e8f99..6a044d41 100644 --- a/src/Filter/ChoiceFilter.php +++ b/src/Filter/ChoiceFilter.php @@ -14,7 +14,6 @@ namespace Sonata\DoctrineMongoDBAdminBundle\Filter; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\AdminBundle\Form\Type\Operator\ContainsOperatorType; use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; @@ -29,15 +28,18 @@ public function getDefaultOptions(): array ]; } - public function getRenderSettings(): array + /** + * @return array + */ + public function getFormOptions(): array { - return [DefaultType::class, [ + return [ 'operator_type' => $this->getOption('operator_type'), 'operator_options' => $this->getOption('operator_options'), 'field_type' => $this->getFieldType(), 'field_options' => $this->getFieldOptions(), 'label' => $this->getLabel(), - ]]; + ]; } protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void diff --git a/src/Filter/IdFilter.php b/src/Filter/IdFilter.php index 983af4d6..4aa05a49 100644 --- a/src/Filter/IdFilter.php +++ b/src/Filter/IdFilter.php @@ -16,7 +16,6 @@ use MongoDB\BSON\ObjectId; use MongoDB\Driver\Exception\InvalidArgumentException; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -31,14 +30,17 @@ public function getDefaultOptions(): array ]; } - public function getRenderSettings(): array + /** + * @return array + */ + public function getFormOptions(): array { - return [DefaultType::class, [ + return [ 'field_type' => $this->getFieldType(), 'field_options' => $this->getFieldOptions(), 'operator_type' => $this->getOption('operator_type'), 'label' => $this->getLabel(), - ]]; + ]; } protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void diff --git a/src/Filter/ModelFilter.php b/src/Filter/ModelFilter.php index 44354a60..d42f3070 100644 --- a/src/Filter/ModelFilter.php +++ b/src/Filter/ModelFilter.php @@ -19,7 +19,6 @@ use MongoDB\BSON\ObjectId; use MongoDB\Driver\Exception\InvalidArgumentException; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\DefaultType; use Sonata\AdminBundle\Form\Type\Operator\EqualOperatorType; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; @@ -36,15 +35,18 @@ public function getDefaultOptions(): array ]; } - public function getRenderSettings(): array + /** + * @return array + */ + public function getFormOptions(): array { - return [DefaultType::class, [ + return [ 'field_type' => $this->getFieldType(), 'field_options' => $this->getFieldOptions(), 'operator_type' => $this->getOption('operator_type'), 'operator_options' => $this->getOption('operator_options'), 'label' => $this->getLabel(), - ]]; + ]; } protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void diff --git a/src/Filter/NumberFilter.php b/src/Filter/NumberFilter.php index a2a5a8ff..a9d0afbd 100644 --- a/src/Filter/NumberFilter.php +++ b/src/Filter/NumberFilter.php @@ -14,7 +14,6 @@ namespace Sonata\DoctrineMongoDBAdminBundle\Filter; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\NumberType; use Sonata\AdminBundle\Form\Type\Operator\NumberOperatorType; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; use Symfony\Component\Form\Extension\Core\Type\NumberType as SymfonyNumberType; @@ -34,13 +33,16 @@ public function getDefaultOptions(): array return ['field_type' => SymfonyNumberType::class]; } - public function getRenderSettings(): array + /** + * @return array + */ + public function getFormOptions(): array { - return [NumberType::class, [ + return [ 'field_type' => $this->getFieldType(), 'field_options' => $this->getFieldOptions(), 'label' => $this->getLabel(), - ]]; + ]; } protected function filter(ProxyQueryInterface $query, string $field, FilterData $data): void diff --git a/src/Filter/StringFilter.php b/src/Filter/StringFilter.php index e599ff8e..7f557194 100644 --- a/src/Filter/StringFilter.php +++ b/src/Filter/StringFilter.php @@ -16,7 +16,6 @@ use Doctrine\ODM\MongoDB\Query\Expr; use MongoDB\BSON\Regex; use Sonata\AdminBundle\Filter\Model\FilterData; -use Sonata\AdminBundle\Form\Type\Filter\ChoiceType; use Sonata\AdminBundle\Form\Type\Operator\ContainsOperatorType; use Sonata\AdminBundle\Search\SearchableFilterInterface; use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQueryInterface; @@ -32,13 +31,16 @@ public function getDefaultOptions(): array ]; } - public function getRenderSettings(): array + /** + * @return array + */ + public function getFormOptions(): array { - return [ChoiceType::class, [ + return [ 'field_type' => $this->getFieldType(), 'field_options' => $this->getFieldOptions(), 'label' => $this->getLabel(), - ]]; + ]; } public function isSearchEnabled(): bool