Uh oh!
There was an error while loading. Please reload this page.
SearchFilter: Refactor code to reduce code duplication and makes it easier to add new strategies to classes inheriting from SearchFilter class - #3541
Conversation
jpierront
commented
May 1, 2020
I'm not sure of what I did for the MongoDbOdm part ;-) |
5a3a193 to
f117591Comparealanpoulain
commented
May 1, 2020
Seems nice! Could you add a Behat test to validate its behavior? It will allow to make sure MongoDB works too. |
| * @throws InvalidArgumentException If strategy does not exist | ||
| */ | ||
| protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, $fieldType, $value, bool $caseSensitive) | ||
| protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, string $alias, string $field, $fieldType, array $values, bool $caseSensitive, string $valueParameter) |
jpierront
commented
May 2, 2020
Finally, by creating the behat tests, I realized that my code was not really doing what I expected.
Finally I’ll just keep the refactoring simplifying the creation of new strategies in the inherited classes. It was what I needed initially ;-) |
7818e75 to
d959323Compare| * | ||
| * @throws InvalidArgumentException If strategy does not exist | ||
| */ | ||
| protected function addEqualityMatchStrategy(string $strategy, Builder $aggregationBuilder, string $matchField, $fieldType, $values, bool $caseSensitive) |
There was a problem hiding this comment.
Since the class is final, it should be private.
There was a problem hiding this comment.
So we allow to extends the ORM version but not the ODM one ? :/
There was a problem hiding this comment.
Yes. Because the ORM version will also be a final class in the next major version (3.0).
jpierront
commented
May 2, 2020
OK, so my original intention will lose its meaning in V3. ;-) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| * @throws InvalidArgumentException If strategy does not exist | ||
| */ | ||
| protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, $fieldType, $value, bool $caseSensitive) | ||
| protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, $fieldType, $values, bool $caseSensitive, string $valueParameter = null) |
There was a problem hiding this comment.
Even like this, it's a BC break. You should mimic what has been done here: #3521.
d6cad23 to
ec51013Compare…asier to add new strategies to classes inheriting from SearchFilter class
ec51013 to
70e2893Comparealanpoulain
commented
Mar 3, 2021
Thanks @jpierront. |
All query manipulations are now located in the same method to ease the creation on classes inherited from SearchFilter.
Example:
We will be able to create easily a "not_int" strategy or more complexe cases.