R
R
Roman2015-05-31 22:09:12
PHP
Roman, 2015-05-31 22:09:12

Doctrine inheritance of entities from entity?

Hello. There is a User entity from which the Person and Employee entities are inherited, and from Person PersonTypeA, PersonTypeB, PersonTypeC. That is, in essence, Person, Employee, PersonTypeA, PersonTypeB, and PersonTypeC extend the User table. But in fact, it turns out that, for example, when saving the entity PersonTypeA, an entry is added to the table "persontypea", "person" and "user". And it is necessary for me that record was added to the table "persontypea" and "user". but I need methods someMethodA, someMethod, and which are used in Person, PersonTypeA, PersonTypeB, PersonTypeC.
Is there a way to tell Doctrine that I only need to inherit methods? Or maybe it's better to do something differently?

/**
 * @Entity
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({
 * "person" = "Person"
 * "persontypea" = "PersonTypeA",
 * "persontypeb" = "PersonTypeB",
 * "persontypec" = "PersonTypeC",
 * "employee" = "Employee"
 * })
 */
abstract class User {

}

/**
 * @Entity
 **/
class Person extends User {
    public function someMethodA() {}

    public function someMethodB() {}
}

/**
 * @Entity
 **/
class PersonTypeA extends Person {

}

/**
 * @Entity
 **/
class PersonTypeB extends Person {

}

/**
 * @Entity
 **/
class PersonTypeC extends Person {

}
/**
 * @Entity
 **/
class Employee extends User {
    
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Antonov, 2015-05-31
@romteh

Mapped Superclasses

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question