Skip to content

Commit f99cc2a

Browse files
committed
bug #797 [Autocomplete] Fix BC and trigger deprecation for EntityAutocompleterInterface (1ed, weaverryan)
This PR was merged into the 2.x branch. Discussion ---------- [Autocomplete] Fix BC and trigger deprecation for `EntityAutocompleterInterface` | Q | A | ------------- | --- | Bug fix? | yes | New feature? | - | Tickets | Fix #793 | License | MIT Commits ------- 4ca03b5 fixing phpcs f530ac1 [Autocomplete] Fix BC and trigger deprecation for `EntityAutocompleterInterface`
2 parents a51d9c9 + 4ca03b5 commit f99cc2a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Autocomplete/src/AutocompleteResultsExecutor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public function fetchResults(EntityAutocompleterInterface $autocompleter, string
7171

7272
$results = [];
7373

74-
if (null === $groupBy = $autocompleter->getGroupBy()) {
74+
if (!method_exists($autocompleter, 'getGroupBy')) {
75+
trigger_deprecation('symfony/ux-autocomplete', '2.8', 'Not implementing the "EntityAutocompleterInterface::getGroupBy()" in "%s" is deprecated.', get_debug_type($autocompleter));
76+
} elseif (null === $groupBy = $autocompleter->getGroupBy()) {
7577
foreach ($paginator as $entity) {
7678
$results[] = [
7779
'value' => $autocompleter->getValue($entity),

src/Autocomplete/src/EntityAutocompleterInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/**
1919
* Interface for classes that will have an "autocomplete" endpoint exposed.
20+
*
21+
* @method mixed getGroupBy() Return group_by option.
2022
*/
2123
interface EntityAutocompleterInterface
2224
{
@@ -47,8 +49,8 @@ public function getValue(object $entity): mixed;
4749
*/
4850
public function isGranted(Security $security): bool;
4951

50-
/**
52+
/*
5153
* Return group_by option.
5254
*/
53-
public function getGroupBy(): mixed;
55+
/* public function getGroupBy(): mixed; */
5456
}

0 commit comments

Comments
 (0)