Skip to content

Commit

Permalink
Stop using deprecated method (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Jul 12, 2022
1 parent 075b181 commit 379cdc7
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 51 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 6 additions & 17 deletions src/Filter/AbstractDateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,23 +41,16 @@ final public function getDefaultOptions(): array
];
}

final public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
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(),
]];
];
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/Filter/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,15 +29,18 @@ public function getDefaultOptions(): array
];
}

public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
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
Expand Down
20 changes: 11 additions & 9 deletions src/Filter/CallbackFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,15 +30,18 @@ public function getDefaultOptions(): array
];
}

public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
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
Expand Down
10 changes: 6 additions & 4 deletions src/Filter/ChoiceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,15 +28,18 @@ public function getDefaultOptions(): array
];
}

public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
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
Expand Down
10 changes: 6 additions & 4 deletions src/Filter/IdFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,14 +30,17 @@ public function getDefaultOptions(): array
];
}

public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
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
Expand Down
10 changes: 6 additions & 4 deletions src/Filter/ModelFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -36,15 +35,18 @@ public function getDefaultOptions(): array
];
}

public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
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
Expand Down
10 changes: 6 additions & 4 deletions src/Filter/NumberFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,13 +33,16 @@ public function getDefaultOptions(): array
return ['field_type' => SymfonyNumberType::class];
}

public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
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
Expand Down
10 changes: 6 additions & 4 deletions src/Filter/StringFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,13 +31,16 @@ public function getDefaultOptions(): array
];
}

public function getRenderSettings(): array
/**
* @return array<string, mixed>
*/
public function getFormOptions(): array
{
return [ChoiceType::class, [
return [
'field_type' => $this->getFieldType(),
'field_options' => $this->getFieldOptions(),
'label' => $this->getLabel(),
]];
];
}

public function isSearchEnabled(): bool
Expand Down

0 comments on commit 379cdc7

Please sign in to comment.