| Q | A
|------------ | ------
| BC Break | no
| Version | latest
Right now there has been one PR closed, and 2 still open for a @DiscriminatorValue since the entire discriminator map currently needs to go into the base class, which means extending classes in a different package will not work with it.
Currently we have an automatic discriminator map, just by removing the annotation. However, two classes with the same name regardless of the namespace will not work.
<?php
namespace Del\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Del\Repository\UserRepository")
* @ORM\Table(name="User",uniqueConstraints={@ORM\UniqueConstraint(name="email_idx", columns={"email"})})
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="class", type="string")
*/
class User
{
// code
}
then try and extend it with another User class in a different namespace:
<?php
namespace OAuth;
use Del\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use League\OAuth2\Server\Entities\UserEntityInterface;
/**
* @ORM\Entity(repositoryClass="OAuth\Repository\UserRepository")
*/
class User extends BaseUser implements UserEntityInterface
{
// code
}
Migrations will generate.
In the meantime, I have just renamed my second user class to OAuthUser. Not ideal but it works.
Unfortunately this can't be changed in BC way so it will have to stay as is in ORM 2.x.
We may deprecate auto-discovery in 3.0 and replace it by @DiscriminatorValue, probably via #6612.
I'll leave it open, but there's nothing we can do in 2.x in this regard.
I thought that might be the case, thanks for letting me know!
Most helpful comment
Unfortunately this can't be changed in BC way so it will have to stay as is in ORM 2.x.
We may deprecate auto-discovery in 3.0 and replace it by
@DiscriminatorValue, probably via #6612.I'll leave it open, but there's nothing we can do in 2.x in this regard.