Connect two consecutive superclasses of doctrine

As you can tell from the title, my question is due to the legacy application I'm using this mapping on:

/** @MappedSuperclass */
abstract class BaseUser
{
    // ... common fields (no associations)
}

/** @Entity */
class Admin extends BaseUser
{
    // ... with specific fields/associations for admin users
}

/** @Entity */
class User extends BaseUser
{
    // ... with specific fields/associations for front-end users
}

      

But now I will need to have 2 different user types with different sections dashboard

, and I thought it would be possible to extend the class User

abstract

with new 2 types as well:

/** @MappedSuperclass */
abstract class User extends BaseUser
{
    // ...
}

/** @Entity */
class StandardUser extends User
{
    // ... with specific fields/associations for standard users
}

/** @Entity */
class AgentUser extends User
{
    // ... with specific fields/associations for agent users
}

      

I'm already doing some research, and obviously I've also read the Doctrine documentation about mapped superclasses , but it hasn't been clearly stated anywhere if it's possible for two or more sequential ones MappedSuperclass

.

So my question is, is this possible? If not, is there an alternative?

PS: I am using Symfony 3.2 and Doctrine 2.5

+3


source to share


1 answer


From my own test on Doctrine 2.5 and Symfony> = 3.2 I can confirm (YES) it is possible to use two or more sequential / chained mapped superclasses without issue.



NOTE. Also, if you see for yourself that it is not a big waste of time, I think this information should be added to the Doctrine docs to clarify any possible duplicate, and because it has no cost at all :-) (but I was the only one, to have this doubt?).

+1


source







All Articles