bug #38604 [DoctrineBridge] indexBy does not refer to attributes, but to column names (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[DoctrineBridge] indexBy does not refer to attributes, but to column names

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37982
| License       | MIT
| Doc PR        |

Commits
-------

af1a6208ec indexBy does not refer to attributes, but to column names
This commit is contained in:
Fabien Potencier 2020-10-17 07:43:29 +02:00
commit 976160914a
3 changed files with 4 additions and 13 deletions

View File

@ -110,19 +110,10 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
$associationMapping = $metadata->getAssociationMapping($property);
if (isset($associationMapping['indexBy'])) {
$indexProperty = $associationMapping['indexBy'];
$indexColumn = $associationMapping['indexBy'];
/** @var ClassMetadataInfo $subMetadata */
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
if (null === $typeOfField) {
$associationMapping = $subMetadata->getAssociationMapping($indexProperty);
/** @var ClassMetadataInfo $subMetadata */
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($indexProperty);
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
}
$typeOfField = $subMetadata->getTypeOfField($subMetadata->getFieldForColumn($indexColumn));
if (!$collectionKeyType = $this->getPhpType($typeOfField)) {
return null;

View File

@ -42,7 +42,7 @@ class DoctrineDummy
public $bar;
/**
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid")
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid_column")
*/
protected $indexedBar;

View File

@ -30,7 +30,7 @@ class DoctrineRelation
public $id;
/**
* @Column(type="guid")
* @Column(type="guid", name="rguid_column")
*/
protected $rguid;