Skip to content

Commit 33b5759

Browse files
committed
refactor: protect BC and trigger a deprecation
1 parent b96f777 commit 33b5759

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Autocomplete/src/AutocompleteResultsExecutor.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\ORM\Tools\Pagination\Paginator;
1515
use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException;
16+
use Symfony\Component\PropertyAccess\PropertyAccessor;
1617
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1718
use Symfony\Component\PropertyAccess\PropertyPath;
1819
use Symfony\Component\PropertyAccess\PropertyPathInterface;
@@ -25,11 +26,22 @@
2526
*/
2627
final class AutocompleteResultsExecutor
2728
{
29+
private PropertyAccessorInterface $propertyAccessor;
30+
private ?Security $security;
31+
2832
public function __construct(
2933
private DoctrineRegistryWrapper $managerRegistry,
30-
private PropertyAccessorInterface $propertyAccessor,
31-
private ?Security $security = null,
34+
$propertyAccessor,
35+
/* Security $security = null */
3236
) {
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+
}
3345
}
3446

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

0 commit comments

Comments
 (0)