Skip to content

Commit 494932a

Browse files
committed
[Autocomplete] Check if LazyChoiceLoader exists before using it
1 parent 7d6adc4 commit 494932a

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

UPGRADE-3.0.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@ the [Symfony documentation](https://symfony.com/doc/6.4/setup/upgrade_major.html
1010
>
1111
> Requires Symfony `6.4` or higher.
1212
13+
## Autocomplete
14+
15+
* The class `ParentEntityAutocompleteType` has been removed in favor of `BaseEntityAutocompleteType`:
16+
```diff
17+
-use Symfony\UX\Autocomplete\Form\ParentEntityAutocompleteType;
18+
+use Symfony\UX\Autocomplete\Form\BaseEntityAutocompleteType;
19+
20+
#[AsEntityAutocompleteField]
21+
class FoodAutocompleteField extends AbstractType
22+
{
23+
// ...
24+
25+
public function getParent(): string
26+
{
27+
- return ParentEntityAutocompleteType::class;
28+
+ return BaseEntityAutocompleteType::class;
29+
}
30+
}
31+
```
32+
33+
* The class `ExtraLazyChoiceLoader` has been removed in favor of
34+
`Symfony\Component\Form\ChoiceList\Loader\LazyChoiceLoader` from Symfony Form >=7.2,
35+
run `composer require symfony/form:>=7.2"` if you don't have it installed yet.
36+
1337
## LazyImage
1438

1539
* The package has been removed, see the [previous README](https://raw.githubusercontent.com/symfony/ux/refs/heads/2.x/src/LazyImage/README.md)

src/Autocomplete/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
- Minimum required Symfony version is now 6.4
66
- Minimum required PHP version is now 8.2
7+
- Remove `ParentEntityAutocompleteType` in favor of `BaseEntityAutocompleteType`
8+
- Remove `ExtraLazyChoiceLoader` in favor of `Symfony\Component\Form\ChoiceList\Loader\LazyChoiceLoader` from Symfony Form >=7.2
9+
- Add parameter `$security` to `AutocompleteResultsExecutor::__construct()`
710

811
## 2.30
912

src/Autocomplete/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"doctrine/orm": "^2.9.4|^3.0",
3838
"fakerphp/faker": "^1.22",
3939
"mtdowling/jmespath.php": "^2.6",
40-
"symfony/form": "^6.4|^7.0|^8.0",
40+
"symfony/form": "^7.2|^8.0",
4141
"symfony/options-resolver": "^6.4|^7.0|^8.0",
4242
"symfony/framework-bundle": "^6.4|^7.0|^8.0",
4343
"symfony/maker-bundle": "^1.40",

src/Autocomplete/src/Form/BaseEntityAutocompleteType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ public function configureOptions(OptionsResolver $resolver): void
4242
return null;
4343
}
4444

45+
if (!class_exists(LazyChoiceLoader::class)) {
46+
throw new \LogicException(sprintf(
47+
'Using "%s" with "%s" requires symfony/form >= 7.2 to be installed. Try running "composer require symfony/form:>=7.2".',
48+
LazyChoiceLoader::class,
49+
__CLASS__,
50+
));
51+
}
52+
4553
return new LazyChoiceLoader($loader);
4654
};
4755

0 commit comments

Comments
 (0)