-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1468 [Autocomplete] Add support for doctrine/orm:^3.0 (evert…
…harmeling) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Autocomplete] Add support for doctrine/orm:^3.0 | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes-ish? | Issues | Replaces #1459 | License | MIT Follow up on #1459 as it seemed a bit more complicated :) Because in the current `getPropertyMetadata` function, [see](https://github.com/symfony/ux/blob/2.x/src/Autocomplete/src/Doctrine/EntityMetadata.php#L44) and below: ```php public function getPropertyMetadata(string $propertyName): array { if (\array_key_exists($propertyName, $this->metadata->fieldMappings)) { return $this->metadata->fieldMappings[$propertyName]; } if (\array_key_exists($propertyName, $this->metadata->associationMappings)) { return $this->metadata->associationMappings[$propertyName]; } throw new \InvalidArgumentException(sprintf('The "%s" field does not exist in the "%s" entity.', $propertyName, $this->metadata->getName())); } ``` The function combines getting metadata from `fieldMappings` and `associationMappings`, that both return an `array` in **Doctrine ORM 2**. This however changes in **Doctrine ORM 3** in `fieldMappings` returning a `FieldMapping` object and `associationMappings` in an `AssociationMapping` object. To support both Doctrine ORM 2 and 3, I didn't changed the return type of the function for now, as we would otherwise need to bump the major version for the `Autocomplete` component. To ease the transition to **Doctrine ORM 3** in the future, I've splitted `getPropertyMetadata` in `getFieldMetadata` and `getAssociationMetadata`. ## TODO - [x] Should we keep the `getPropertyMetadata()` function as a proxy to the new methods? (I removed it for now as the method shouldn't be used directly as [mentioned](#1459 (comment)). - [x] Should we retroactively add the ``@internal`` the `src/Autocomplete/src/Doctrine/EntityMetadata.php` class also (as [mentioned](#1459 (comment)))? - [ ] Test on Doctrine ORM 3, currently blocked by zenstruck/foundry#556 Commits ------- 20f4dad [Autocomplete] Add support for doctrine/orm:^3.0
- Loading branch information
Showing
5 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters