sonata-project/SonataDoctrineORMAdminBundle

The ModelAutocompleteType is a duplicated class of ModelFilter with a different field_type.

VincentLanglet opened this issue · 0 comments

I took a look at #1040, I wanted to see what was missing to fix the issue ; so I looked at the difference between ModelFilter and ModelAutocompleteType.

  1. The filter method is the same
  2. The handle multiple method is the same, except that ModelFilter add the null check for NotEqual
  3. The handle single method is the same, except that ModelFilter add the null check for NotEqual
  4. The association method is the same, except that ModelFilter add a check about allowed values for mapping type
  5. ModelFilter has a private method getParentAlias needed for the null check
  6. ModelFilter has a 'mapping_type' option.
  7. ModelFilter has a 'field_type' => EntityType::class, default option when ModelAutocompleteFilter use ModelAutocompleteType.

If we change NotEqual behavior to return null value too in ModelAutocompleteFilter, the differences 2, 3, 4, 5, 6 won't be.

So ModelAutocompleteFilter will be a duplicate of ModelFilter with just a config diff.

Should we then deprecate the ModelAutocompleteFilter, in favor of

->add('foo', ModelType::class, [
     'field_type' => ModelAutocompleteType::class, 
])

?