Skip to content

Commit

Permalink
- adapted FilterBundle to work with attributes instead of doctrine an…
Browse files Browse the repository at this point in the history
…notation

- added @return annotation to MetaclassFilterExtension
- allowed symfony 7 in composer json of FilterBundle
  • Loading branch information
metaclass-nl committed Jan 12, 2024
1 parent 8c0efdd commit 88762fb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/MetaclassFilterExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class MetaclassFilterExtension extends Extension
{
/**
* {@inheritDoc}
* @return void
*/
public function load(array $configs, ContainerBuilder $container)
{
Expand Down
36 changes: 19 additions & 17 deletions tests/Entity/TestEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"])]
Expand All @@ -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;
}
19 changes: 12 additions & 7 deletions tests/Entity/TestRelated.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,50 @@
* @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;

/**
* @var TestEntity
* @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;
}

0 comments on commit 88762fb

Please sign in to comment.