Skip to content

Commit

Permalink
Stopped using deprecated Doctrine classes
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Apr 28, 2020
1 parent 75e588a commit 3cf4429
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
1 change: 0 additions & 1 deletion src/Contracts/Controller/DashboardControllerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\User\UserInterface;
Expand Down
47 changes: 24 additions & 23 deletions src/Factory/FieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace EasyCorp\Bundle\EasyAdminBundle\Factory;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto;
Expand All @@ -28,29 +29,29 @@ final class FieldFactory
// TODO: update this map when ArrayField is implemented
private static $doctrineTypeToFieldFqcn = [
//Type::TARRAY => 'array',
Type::BIGINT => TextField::class,
Type::BINARY => TextareaField::class,
Type::BLOB => TextareaField::class,
Type::BOOLEAN => BooleanField::class,
Type::DATE => DateField::class,
Type::DATE_IMMUTABLE => DateField::class,
Type::DATEINTERVAL => TextField::class,
Type::DATETIME => DateTimeField::class,
Type::DATETIME_IMMUTABLE => DateTimeField::class,
Type::DATETIMETZ => DateTimeField::class,
Type::DATETIMETZ_IMMUTABLE => DateTimeField::class,
Type::DECIMAL => NumberField::class,
Type::FLOAT => NumberField::class,
Type::GUID => TextField::class,
Type::INTEGER => IntegerField::class,
Type::JSON => TextField::class,
Type::OBJECT => TextField::class,
//Type::SIMPLE_ARRAY => 'array',
Type::SMALLINT => IntegerField::class,
Type::STRING => TextField::class,
Type::TEXT => TextareaField::class,
Type::TIME => TimeField::class,
Type::TIME_IMMUTABLE => TimeField::class,
Types::BIGINT => TextField::class,
Types::BINARY => TextareaField::class,
Types::BLOB => TextareaField::class,
Types::BOOLEAN => BooleanField::class,
Types::DATE_MUTABLE => DateField::class,
Types::DATE_IMMUTABLE => DateField::class,
Types::DATEINTERVAL => TextField::class,
Types::DATETIME_MUTABLE => DateTimeField::class,
Types::DATETIME_IMMUTABLE => DateTimeField::class,
Types::DATETIMETZ_MUTABLE => DateTimeField::class,
Types::DATETIMETZ_IMMUTABLE => DateTimeField::class,
Types::DECIMAL => NumberField::class,
Types::FLOAT => NumberField::class,
Types::GUID => TextField::class,
Types::INTEGER => IntegerField::class,
Types::JSON => TextField::class,
Types::OBJECT => TextField::class,
//Types::SIMPLE_ARRAY => 'array',
Types::SMALLINT => IntegerField::class,
Types::STRING => TextField::class,
Types::TEXT => TextareaField::class,
Types::TIME_MUTABLE => TimeField::class,
Types::TIME_IMMUTABLE => TimeField::class,
];

private $adminContextProvider;
Expand Down
50 changes: 25 additions & 25 deletions src/Factory/FilterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EasyCorp\Bundle\EasyAdminBundle\Factory;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface;
Expand All @@ -26,30 +26,30 @@ final class FilterFactory
private $adminContextProvider;
private $filterConfigurators;
private static $doctrineTypeToFilterClass = [
Type::JSON_ARRAY => ArrayFilter::class,
Type::SIMPLE_ARRAY => ArrayFilter::class,
Type::TARRAY => ArrayFilter::class,
Type::JSON => TextFilter::class,
Type::BOOLEAN => BooleanFilter::class,
Type::DATE => DateTimeFilter::class,
Type::DATE_IMMUTABLE => DateTimeFilter::class,
Type::TIME => DateTimeFilter::class,
Type::TIME_IMMUTABLE => DateTimeFilter::class,
Type::DATETIME => DateTimeFilter::class,
Type::DATETIMETZ => DateTimeFilter::class,
Type::DATETIME_IMMUTABLE => DateTimeFilter::class,
Type::DATETIMETZ_IMMUTABLE => DateTimeFilter::class,
Type::DATEINTERVAL => ComparisonFilter::class,
Type::DECIMAL => NumericFilter::class,
Type::FLOAT => NumericFilter::class,
Type::BIGINT => NumericFilter::class,
Type::INTEGER => NumericFilter::class,
Type::SMALLINT => NumericFilter::class,
Type::GUID => TextFilter::class,
Type::STRING => TextFilter::class,
Type::BLOB => TextFilter::class,
Type::OBJECT => TextFilter::class,
Type::TEXT => TextFilter::class,
'json_array' => ArrayFilter::class,
Types::SIMPLE_ARRAY => ArrayFilter::class,
Types::ARRAY => ArrayFilter::class,
Types::JSON => TextFilter::class,
Types::BOOLEAN => BooleanFilter::class,
Types::DATE_MUTABLE => DateTimeFilter::class,
Types::DATE_IMMUTABLE => DateTimeFilter::class,
Types::TIME_MUTABLE => DateTimeFilter::class,
Types::TIME_IMMUTABLE => DateTimeFilter::class,
Types::DATETIME_MUTABLE => DateTimeFilter::class,
Types::DATETIMETZ_MUTABLE => DateTimeFilter::class,
Types::DATETIME_IMMUTABLE => DateTimeFilter::class,
Types::DATETIMETZ_IMMUTABLE => DateTimeFilter::class,
Types::DATEINTERVAL => ComparisonFilter::class,
Types::DECIMAL => NumericFilter::class,
Types::FLOAT => NumericFilter::class,
Types::BIGINT => NumericFilter::class,
Types::INTEGER => NumericFilter::class,
Types::SMALLINT => NumericFilter::class,
Types::GUID => TextFilter::class,
Types::STRING => TextFilter::class,
Types::BLOB => TextFilter::class,
Types::OBJECT => TextFilter::class,
Types::TEXT => TextFilter::class,
];

public function __construct(AdminContextProvider $adminContextProvider, iterable $filterConfigurators)
Expand Down
6 changes: 3 additions & 3 deletions src/Filter/Configurator/NumericConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EasyCorp\Bundle\EasyAdminBundle\Filter\Configurator;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
Expand All @@ -26,11 +26,11 @@ public function configure(FilterDto $filterDto, ?FieldDto $fieldDto, EntityDto $
{
$propertyType = $entityDto->getPropertyMetadata($filterDto->getProperty())->get('type');

if (Type::DECIMAL === $propertyType) {
if (Types::DECIMAL === $propertyType) {
$filterDto->setFormTypeOptionIfNotSet('value_type_options.input', 'string');
}

if (\in_array($propertyType, [Type::BIGINT, Type::INTEGER, Type::SMALLINT], true)) {
if (\in_array($propertyType, [Types::BIGINT, Types::INTEGER, Types::SMALLINT], true)) {
$filterDto->setFormTypeOptionIfNotSet('value_type', IntegerType::class);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Filter/Configurator/TextConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EasyCorp\Bundle\EasyAdminBundle\Filter\Configurator;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
Expand All @@ -26,11 +26,11 @@ public function configure(FilterDto $filterDto, ?FieldDto $fieldDto, EntityDto $
{
$propertyType = $entityDto->getPropertyMetadata($filterDto->getProperty())->get('type');

if (Type::JSON === $propertyType) {
if (Types::JSON === $propertyType) {
$filterDto->setFormTypeOption('value_type', TextareaType::class);
}

if (\in_array($propertyType, [Type::BLOB, Type::OBJECT, Type::TEXT], true)) {
if (\in_array($propertyType, [Types::BLOB, Types::OBJECT, Types::TEXT], true)) {
$filterDto->setFormTypeOptionIfNotSet('value_type', TextareaType::class);
}
}
Expand Down

0 comments on commit 3cf4429

Please sign in to comment.