mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Why maps bundle class when should not? #6192
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BonBonSlick on GitHub (Mar 1, 2019).
Originally assigned to: @Ocramius on GitHub.
Support Question
We have own package bundle with abstract entity and default preset fields.
To make it work in project we create entity eg
namespace App\Entity;
use PackageName\BundleName\Entity\AbstractFaq;
use Doctrine\ORM\Mapping as ORM;
Exception during migration diff
[2019-03-01 15:14:29] request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\Mapping\MappingException: "Class "PackageName\BundleName\Entity\AbstractFaq" is not a valid entity or mapped super class." at /srv/oppasland/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php line 346 {"exception":"[object] (Doctrine\\ORM\\Mapping\\MappingException(code: 0): Class ....Tell me please what I am missing?
@BonBonSlick commented on GitHub (Mar 1, 2019):
Found solution, the reason is that in our own, custom package, bundle we do
But have to map to entity in project, eg App\Entity\Faq.
But this way we bind entity path. Is there other way?
@Ocramius commented on GitHub (Mar 1, 2019):
Could you elaborate a bit more? This isn't clear to me.
@BonBonSlick commented on GitHub (Mar 4, 2019):
We have created bundle alike FOSUser.
There is entity in that package called AbstractFaq.
When some project installs package it has to create own FAQ entity and extend AbstractFaq form the bundle.
AbstractFaq has mappings as annotations. (This way simpler to maintain because package is small).
FosUser and FosUser mapping
Validation is made with DTO
Issue is, in FOS user bundle, repository get by class
please note there is no checks if this is subclass or interface. FOS binds class with configs.
No checks or typehints like FaqInterface or UserInterface when getting repository with getRepository.
To my mind this way is error prone.
As I described above, we bind, hardcode for typehinting.
Is there any other way to know path to entity in project and load it to create query builder, query?
@Ocramius commented on GitHub (Mar 4, 2019):
See https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/resolve-target-entity-listener.html
@BonBonSlick commented on GitHub (Mar 8, 2019):
@Ocramius Thank you!