api-platform / api-platform/core

`DateFilter` does not work with custom Doctrine ORM date types

Open
#8,074 4 comments 7 reactions 0 assignees View on GitHub
doctrine
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 5h
Merged PRs (30d)
48

Description

**API Platform version(s) affected**: 2.7.11

**Description**

I have a custom Doctrine ORM type for my date fields. Nothing special, only changes the format of the date string to be written to the database to add microtime.

The trouble is, `DateFilter` does not work with it, because it checks if the field type is in the list of hardcoded Doctrine types specified via `ApiPlatform\Doctrine\Orm\Filter\DateFilter::DOCTRINE_DATE_TYPES`.

Since the `DateFilter` class is final and all of it's methods are protected, I have no effective way of injecting my own Doctrine type into `DateFilter`, either by extending or decorating the filter class. The only way is to copy and paste the entire implementation which is not ideal.

I would like to see `DateFilter` improved to somehow allow flagging my own Doctrine type as safe to use by the filter.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.