From 0aadc0060cba82f4a25ffe95dd5de3e424c10b2c Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 20 Dec 2024 14:07:43 +0200 Subject: [PATCH] [Autocomplete] Deprecate `ExtraLazyChoiceLoader` in favor of `LazyChoiceLoader` # Conflicts: # src/Autocomplete/CHANGELOG.md --- src/Autocomplete/CHANGELOG.md | 1 + src/Autocomplete/src/Form/BaseEntityAutocompleteType.php | 5 +++++ .../src/Form/ChoiceList/Loader/ExtraLazyChoiceLoader.php | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/Autocomplete/CHANGELOG.md b/src/Autocomplete/CHANGELOG.md index 2498c7b9bfb..1f8cea05633 100644 --- a/src/Autocomplete/CHANGELOG.md +++ b/src/Autocomplete/CHANGELOG.md @@ -2,6 +2,7 @@ ## 2.23.0 +- Deprecate `ExtraLazyChoiceLoader` in favor of `Symfony\Component\Form\ChoiceList\Loader\LazyChoiceLoader` - Reset TomSelect when updating url attribute #1505 ## 2.22.0 diff --git a/src/Autocomplete/src/Form/BaseEntityAutocompleteType.php b/src/Autocomplete/src/Form/BaseEntityAutocompleteType.php index f4e002d0fe4..18804b7753f 100644 --- a/src/Autocomplete/src/Form/BaseEntityAutocompleteType.php +++ b/src/Autocomplete/src/Form/BaseEntityAutocompleteType.php @@ -13,6 +13,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\ChoiceList\Loader\LazyChoiceLoader; use Symfony\Component\Form\Exception\RuntimeException; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\Options; @@ -42,6 +43,10 @@ public function configureOptions(OptionsResolver $resolver): void return null; } + if (class_exists(LazyChoiceLoader::class)) { + return new LazyChoiceLoader($loader); + } + return new ExtraLazyChoiceLoader($loader); }; diff --git a/src/Autocomplete/src/Form/ChoiceList/Loader/ExtraLazyChoiceLoader.php b/src/Autocomplete/src/Form/ChoiceList/Loader/ExtraLazyChoiceLoader.php index dfa3b0b409e..8f49ab4b653 100644 --- a/src/Autocomplete/src/Form/ChoiceList/Loader/ExtraLazyChoiceLoader.php +++ b/src/Autocomplete/src/Form/ChoiceList/Loader/ExtraLazyChoiceLoader.php @@ -17,6 +17,8 @@ /** * Loads choices on demand only. + * + * @deprecated since Autocomplete 2.23 and will be removed in 3.0, use `Symfony\Component\Form\ChoiceList\Loader\LazyChoiceLoader` instead. */ class ExtraLazyChoiceLoader implements ChoiceLoaderInterface {