From 88762fb2fd6e30cbc7744ca25fc4bc132c961ef9 Mon Sep 17 00:00:00 2001 From: henk Date: Fri, 12 Jan 2024 14:23:31 +0100 Subject: [PATCH] - adapted FilterBundle to work with attributes instead of doctrine annotation - added @return annotation to MetaclassFilterExtension - allowed symfony 7 in composer json of FilterBundle --- composer.json | 2 +- .../MetaclassFilterExtension.php | 1 + tests/Entity/TestEntity.php | 36 ++++++++++--------- tests/Entity/TestRelated.php | 19 ++++++---- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index e274c6d..036140b 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "minimum-stability": "dev", "require": { "php": ">=7.2.5", - "symfony/http-kernel": "^4.4 || ^5.1 || ^6.0", + "symfony/http-kernel": "^4.4 || ^5.1 || ^6.0 || ^7.0", "api-platform/core": "^2.7 || ^3.0", "doctrine/orm": "^2.7" }, diff --git a/src/DependencyInjection/MetaclassFilterExtension.php b/src/DependencyInjection/MetaclassFilterExtension.php index 4b660c6..268751d 100644 --- a/src/DependencyInjection/MetaclassFilterExtension.php +++ b/src/DependencyInjection/MetaclassFilterExtension.php @@ -17,6 +17,7 @@ class MetaclassFilterExtension extends Extension { /** * {@inheritDoc} + * @return void */ public function load(array $configs, ContainerBuilder $container) { diff --git a/tests/Entity/TestEntity.php b/tests/Entity/TestEntity.php index 76a4221..cd4f5ee 100644 --- a/tests/Entity/TestEntity.php +++ b/tests/Entity/TestEntity.php @@ -18,15 +18,8 @@ /** * Class TestEntity * @package Metaclass\FilterBundle\Entity - * @ORM\Entity - * ApiResource - * ApiFilter(DateFilter::class, properties={"dd": DateFilterInterface::INCLUDE_NULL_AFTER}) - * ApiFilter(ExistsFilter::class, properties={"dd", "bool", "toMany.bool"}) - * ApiFilter(AddFakeLeftJoin::class) - * ApiFilter(SearchFilter::class, properties={"toMany.text"}) - * ApiFilter(FilterLogic::class, arguments={"innerJoinsLeft"=true}) - * ApiFilter(RemoveFakeLeftJoin::class) */ +#[ORM\Entity] #[ApiResource] #[ApiFilter(DateFilter::class, properties: ["dd" => DateFilterInterface::INCLUDE_NULL_AFTER])] #[ApiFilter(ExistsFilter::class, properties: ["dd", "bool", "toMany.bool"])] @@ -39,45 +32,54 @@ class TestEntity /** * @var int The entity Id * - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(type="integer") + * ORM\Id + * ORM\GeneratedValue + * ORM\Column(type="integer") */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type:"integer")] public $id = 0; /** * @var float - * @ORM\Column(type="float") + * ORM\Column(type="float") */ + #[ORM\Column(type:"float")] public $numb = 0.0; /** * @var string - * @ORM\Column + * ORM\Column */ + #[ORM\Column] public $text; /** * @var \DateTime|null - * @ORM\Column(type="date", nullable=true) + * ORM\Column(type="date", nullable=true) */ + #[ORM\Column(type:"date", nullable:true)] public $dd; /** * @var bool|null - * @ORM\Column(type="boolean", nullable=true) + * ORM\Column(type="boolean", nullable=true) */ + #[ORM\Column(type:"boolean", nullable:true)] public $bool; /** * @var TestRelated - * @ORM\ManyToOne(targetEntity="Metaclass\FilterBundle\Entity\TestRelated", inversedBy="toMany") + * ORM\ManyToOne(targetEntity="Metaclass\FilterBundle\Entity\TestRelated", inversedBy="toMany") */ + #[ORM\ManyToOne(targetEntity:"Metaclass\FilterBundle\Entity\TestRelated", inversedBy:"toMany")] public $toOneNullable; /** * @var Collection - * @ORM\OneToMany(targetEntity="Metaclass\FilterBundle\Entity\TestRelated", mappedBy="project") + * ORM\OneToMany(targetEntity="Metaclass\FilterBundle\Entity\TestRelated", mappedBy="project") */ + #[ORM\OneToMany(targetEntity:"Metaclass\FilterBundle\Entity\TestRelated", mappedBy:"project")] public $toMany; } \ No newline at end of file diff --git a/tests/Entity/TestRelated.php b/tests/Entity/TestRelated.php index c748c09..dbd2cd3 100644 --- a/tests/Entity/TestRelated.php +++ b/tests/Entity/TestRelated.php @@ -10,39 +10,42 @@ * @package Metaclass\FilterBundle\Entity * @ORM\Entity */ +#[ORM\Entity] class TestRelated { /** * @var int The entity Id - * - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(type="integer") */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type:"integer")] public $id = 0; /** * @var float - * @ORM\Column(type="float") */ + #[ORM\Column(type:"float")] public $numb = 0.0; /** * @var string - * @ORM\Column + * ORM\Column */ + #[ORM\Column] public $text; /** * @var \DateTime|null - * @ORM\Column(type="date", nullable=true) + * ORM\Column(type="date", nullable=true) */ + #[ORM\Column(type:"date", nullable:true)] public $dd; /** * @var bool|null * @ORM\Column(type="boolean", nullable=true) */ + #[ORM\Column(type:"boolean", nullable:true)] public $bool; /** @@ -50,5 +53,7 @@ class TestRelated * @ORM\ManyToOne(targetEntity="Metaclass\FilterBundle\Entity\TestEntity", inversedBy="toMany") * @ORM\JoinColumn(referencedColumnName="id", nullable=false) */ + #[ORM\ManyToOne(targetEntity:"Metaclass\FilterBundle\Entity\TestEntity", inversedBy:"toMany")] + #[ORM\JoinColumn(referencedColumnName:"id", nullable:false)] public $testEntity; } \ No newline at end of file