/** @test */
 public function the_filter_can_be_set_again()
 {
     $qb = $this->em->getRepository(Post::class)->createQueryBuilder('x');
     $builder = new FilterBuilder();
     $posts = $builder->setQueryBuilder($qb)->setFilter($this->filter)->getResult(['title' => 'Post title']);
     $this->assertCount(1, $posts);
     // Change filter
     $this->filter->defineFilter(function (FilterBuilder $builder) {
         $builder->add('content', LikeFilterType::class);
     });
     // Query again with new filter
     $posts = $builder->setFilter($this->filter)->getResult(['title' => 'Should be ignored', 'content' => 'post content']);
     $this->assertCount(1, $posts);
 }
 /**
  * @param FilterBuilder $builder
  * @param $entity
  * @param EntityManager $em
  * @param ApiResource $parentResource
  * @param string $prefix
  */
 protected function addFilterForParent(FilterBuilder $builder, $entity, EntityManager $em, ApiResource $parentResource, $prefix = '')
 {
     $meta = $em->getClassMetadata($entity);
     $mappings = $this->getAssociationMappings($meta, $parentResource->getEntityClass());
     $builder->add(self::getFilterName($parentResource), EqualFilterType::class, ['fields' => $this->getFields($prefix, $mappings)]);
     if ($parentsParent = $parentResource->getParentResource()) {
         $this->addFilterForParent($builder, $parentResource->getEntityClass(), $em, $parentsParent, $parentResource->getAssocSubResource() . '.');
     }
 }
 public function buildFilter(FilterBuilder $builder)
 {
     $builder->add('title', LikeFilterType::class)->add('content', LikeFilterType::class)->add('createdAt', BetweenFilterType::class);
 }