Skip to content

Commit ed63e1a

Browse files
[Autocomplete] Triggered deprecation on getPropertyMetadata method + updated return doc
1 parent 90eb282 commit ed63e1a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Autocomplete/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"require": {
2727
"php": ">=8.1",
2828
"symfony/dependency-injection": "^6.3|^7.0",
29+
"symfony/deprecation-contracts": "^2.5|^3",
2930
"symfony/http-foundation": "^6.3|^7.0",
3031
"symfony/http-kernel": "^6.3|^7.0",
3132
"symfony/property-access": "^6.3|^7.0",

src/Autocomplete/src/Doctrine/EntityMetadata.php

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

44+
public function getPropertyMetadata(string $propertyName): array
45+
{
46+
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.');
47+
48+
try {
49+
return $this->getFieldMetadata($propertyName);
50+
} catch (\InvalidArgumentException $e) {
51+
return $this->getAssociationMetadata($propertyName);
52+
}
53+
}
54+
55+
/**
56+
* @internal
57+
* @return array<string, mixed>
58+
*/
4459
public function getFieldMetadata(string $propertyName): array
4560
{
4661
if (\array_key_exists($propertyName, $this->metadata->fieldMappings)) {
@@ -57,6 +72,10 @@ public function getFieldMetadata(string $propertyName): array
5772
throw new \InvalidArgumentException(sprintf('The "%s" field does not exist in the "%s" entity.', $propertyName, $this->metadata->getName()));
5873
}
5974

75+
/**
76+
* @internal
77+
* @return array<string, mixed>
78+
*/
6079
public function getAssociationMetadata(string $propertyName): array
6180
{
6281
if (\array_key_exists($propertyName, $this->metadata->associationMappings)) {

0 commit comments

Comments
 (0)