php - Why does Symfony API Platform ignore filters? ← (PHP, Symfony)
one text
I am working on a Symfony 5 + API Platform project. I am still fighting with API Filters. I made this work before setting up a fake API route from some controller. But, since there is an API Platform out of the box feature that allow this, I would like to "make" this work.
First of all, the entity filters are being ignored and API Platform is aware of that. According to Symfony Profiler > API Platform > Resource Metadata :
And according to Data Providers tab in the same page:
What I have tried so far is adding @ApiFilter()
annotation to Question
entity like API documentation explains:
// ...
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=QuestionRepository::class)
* @ApiResource(normalizationContext={"groups"={"question"}})
* @ApiFilter(SearchFilter::class, properties={"status": "partial"})
*/
class Question
{
// ...
/**
* @ORM\Column(type="string", length=255)
* @Groups("question")
*/
private $status;
// ...
}
I also have tried to specify the filter on the needed property to be filtered. (Thanks to @EugeneRuban from a previous question).
So that, why does API Platform ignores the filter?
Edit: This is what the Logs shows:
Source
See also:
About the technologies asked in this question PHP PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.https://www.php.net/
Symfony Symfony compares favorably with other PHP frameworks in terms of reliability and maturity. This framework appeared a long time ago, in 2005, that is, it has existed much longer than most of the other tools we are considering. It is popular for its web standards compliance and PHP design patterns.https://symfony.com/
Welcome to programmierfrage.com
programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.
Get answers to specific questions
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Help Others Solve Their Issues
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.