Skip to content

Commit 532a5e1

Browse files
smnandreKocal
authored andcommitted
[Autocomplete] Remove deprecations for 3.0
1 parent c30afe1 commit 532a5e1

File tree

10 files changed

+33
-319
lines changed

10 files changed

+33
-319
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/AutocompleteResultsExecutor.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Doctrine\ORM\Tools\Pagination\Paginator;
1515
use Symfony\Bundle\SecurityBundle\Security;
1616
use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException;
17-
use Symfony\Component\PropertyAccess\PropertyAccessor;
1817
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1918
use Symfony\Component\PropertyAccess\PropertyPath;
2019
use Symfony\Component\PropertyAccess\PropertyPathInterface;
@@ -26,22 +25,11 @@
2625
*/
2726
final class AutocompleteResultsExecutor
2827
{
29-
private PropertyAccessorInterface $propertyAccessor;
30-
private ?Security $security;
31-
3228
public function __construct(
3329
private DoctrineRegistryWrapper $managerRegistry,
34-
$propertyAccessor,
35-
/* Security $security = null */
30+
private PropertyAccessorInterface $propertyAccessor,
31+
private ?Security $security = null,
3632
) {
37-
if ($propertyAccessor instanceof Security) {
38-
trigger_deprecation('symfony/ux-autocomplete', '2.8.0', 'Passing a "%s" instance as the second argument of "%s()" is deprecated, pass a "%s" instance instead.', Security::class, __METHOD__, PropertyAccessorInterface::class);
39-
$this->security = $propertyAccessor;
40-
$this->propertyAccessor = new PropertyAccessor();
41-
} else {
42-
$this->propertyAccessor = $propertyAccessor;
43-
$this->security = \func_num_args() >= 3 ? func_get_arg(2) : null;
44-
}
4533
}
4634

4735
public function fetchResults(EntityAutocompleterInterface $autocompleter, string $query, int $page): AutocompleteResults

src/Autocomplete/src/DependencyInjection/AutocompleteExtension.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField;
3030
use Symfony\UX\Autocomplete\Form\AutocompleteChoiceTypeExtension;
3131
use Symfony\UX\Autocomplete\Form\BaseEntityAutocompleteType;
32-
use Symfony\UX\Autocomplete\Form\ParentEntityAutocompleteType;
3332
use Symfony\UX\Autocomplete\Form\WrappedEntityTypeAutocompleter;
3433
use Symfony\UX\Autocomplete\Maker\MakeAutocompleteField;
3534

@@ -147,14 +146,6 @@ private function registerFormServices(ContainerBuilder $container): void
147146
])
148147
->addTag('form.type');
149148

150-
$container
151-
->register('ux.autocomplete.entity_type', ParentEntityAutocompleteType::class)
152-
->setDeprecated('symfony/ux-autocomplete', '2.13', 'The "%service_id%" form type is deprecated since 2.13. Use "ux.autocomplete.base_entity_type" instead.')
153-
->setArguments([
154-
new Reference('router'),
155-
])
156-
->addTag('form.type');
157-
158149
$container
159150
->register('ux.autocomplete.choice_type_extension', AutocompleteChoiceTypeExtension::class)
160151
->setArguments([

src/Autocomplete/src/Doctrine/EntityMetadata.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@ public function isEmbeddedClassProperty(string $propertyName): bool
4242
return \array_key_exists($propertyNameParts[0], $this->metadata->embeddedClasses);
4343
}
4444

45-
public function getPropertyMetadata(string $propertyName): array
46-
{
47-
trigger_deprecation('symfony/ux-autocomplete', '2.15.0', 'Calling EntityMetadata::getPropertyMetadata() is deprecated. You should stop using it, as it will be removed in the future.');
48-
49-
try {
50-
return $this->getFieldMetadata($propertyName);
51-
} catch (\InvalidArgumentException $e) {
52-
return $this->getAssociationMetadata($propertyName);
53-
}
54-
}
55-
5645
/**
5746
* @internal
5847
*

src/Autocomplete/src/Form/AutocompleteEntityTypeSubscriber.php

Lines changed: 0 additions & 110 deletions
This file was deleted.

src/Autocomplete/src/Form/BaseEntityAutocompleteType.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\OptionsResolver\Options;
2020
use Symfony\Component\OptionsResolver\OptionsResolver;
2121
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
22-
use Symfony\UX\Autocomplete\Form\ChoiceList\Loader\ExtraLazyChoiceLoader;
2322

2423
/**
2524
* All form types that want to expose autocomplete functionality should use this for its getParent().
@@ -43,11 +42,11 @@ public function configureOptions(OptionsResolver $resolver): void
4342
return null;
4443
}
4544

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

50-
return new ExtraLazyChoiceLoader($loader);
49+
return new LazyChoiceLoader($loader);
5150
};
5251

5352
$resolver->setDefaults([

src/Autocomplete/src/Form/ChoiceList/Loader/ExtraLazyChoiceLoader.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)