api platform, can’t add a custom search filter to an abstract class using symfony 4

I’m trying to create a custom search filter to an abstract class, i want to be able to search by one keyword .

The search filter code :

public function getDescription(string $resourceClass): array
    {
        $reader = new AnnotationReader();
        $annotation = $reader->getClassAnnotation(new ReflectionClass(new $resourceClass), SearchAnnotation::class);

        $description['search'] = [
            'property' => 'search',
            'type' => 'string',
            'required' => false,
            'swagger' => ['description' => 'FullTextFilter on ' . implode(', ', $annotation->fields)],
        ];

        return $description;
    }

The custom search try to get a new instance of the resource class but in my case it’s an abstract class and i got an error about :

Cannot instantiate abstract class.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *