Question: How symfony plugin detects Doctrine mapping driver ?
Hi @Haehnchen ,
Firstly thanks for the awesome plugin. It helps a lot with doctrine.
I'm using doctrine in non-symfony environment and with your plugin I had no auto-complete problems when using annotations mappings. Since I've converted everything to Attribute mapping, auto-complete stopped working for joins. Suggestions show correctly in 'select()` though.

I assume this is because annotation is default driver in plugin.
Is there any way to tell the plugin which mapping driver I am using ?
Thanks!
Any ideas ?
Just add in, I'm working in Laravel with Laravel-doctrine package. Any help will be greatly appreciated.
Thanks
sry totally missed this request.
fyi: I have have still in mind, that relations inside php attributes changed "somehow or simplified" in Doctrine. Its already on my todo list to check and extract in "the wild" project cases.
- Feel free to provide code snippets on how you used the joins for attributes; would make it easier here.
- by design the logic is not limited to a Symfony project and was done right from the beginning; improvements can also be done if on detection
are you having still any completion at all? e.g. field completion inside select for fields, for this snippet?
All mapping drivers iterated per file, so there no detection involved:
fr.adrienbrault.idea.symfony2plugin.doctrine.metadata.util.DoctrineMetadataUtil#MAPPING_DRIVERS
php attribute driver is located here:
https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/3598fb010ec6b4647a6ceb27ed20fd656a25df72/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/driver/DoctrinePhpAttributeMappingDriver.java#L29
I think a problem might be if you omit the targetEntity of the attribute when using typed properties.
When using a *ToOne attribute, Doctrine allows you to omit the targetEntity if you type the property itself.
The attribute mapping driver appears to explicitly look only for the targetEntity of the attribute and does not take a look at the property type itself:
https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/3598fb010ec6b4647a6ceb27ed20fd656a25df72/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/driver/DoctrinePhpAttributeMappingDriver.java#L93
As soon as I added targetEntity to each attribute, autocomplete started populating as expected within queries.
I've found that autocompletion didn't work when mappings are set to PHP attributes and having targetEntity typed as string, ie:
This doesn't work:
#[ORM\OneToOne(targetEntity: 'App\Entities\Employees')]
#[ORM\OneToOne(targetEntity: '\App\Entities\Employees')]
This works:
#[ORM\OneToOne(targetEntity: \App\Entities\Employees:class)]
@soltmar
Indeed, it appears that the code then expects that the targetEntity of the attribute is a class constant:
https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/e73cff8726853a70a54f2453c4a22011af67bb2e/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/driver/DoctrinePhpAttributeMappingDriver.java#L93-L99
But this portion is probably written this way because referencing a class by using ::class is the recommended way, rather than a hard-coded string.
@soltmar i just added your case.
@soltmar Indeed, it appears that the code then expects that the
targetEntityof the attribute is a class constant:https://github.com/Haehnchen/idea-php-symfony2-plugin/blob/e73cff8726853a70a54f2453c4a22011af67bb2e/src/main/java/fr/adrienbrault/idea/symfony2plugin/doctrine/metadata/driver/DoctrinePhpAttributeMappingDriver.java#L93-L99
But this portion is probably written this way because referencing a class by using
::classis the recommended way, rather than a hard-coded string.
Yeah, but this was a "leftover" in my case when converting legacy entities to attribute based mappings.
@Haehnchen, thanks :)