In Doctrine2, when you have your parent entity class, Person
set as:
/**
* @Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"person" = "Person", "employee" = "Employee", , "client" = "Client"})
*/
class Person
{
// ...
}
and sub classes such as Client
set as:
/** @Entity */
class Client extends Person
{
// ...
}
when you instantiate Person
as:
$person = new Person();
Doctrine2 checks your @DiscriminatorMap
statement (above) for a corresponding mapping to Person
and when found, creates a string value in the table column set in @DiscriminatorColumn
above.
So when you decide to have an instance of Client
as:
$client = new Client();
Following these principles, Doctrine2 will create an instance for you as long as you have declared the parameters in the @DiscriminatorMap
. Also an entry will be made on the Person
table, in the discr column to reflect that type of entity class that has just been instantiated.
Hope that helps. It's all in the documentation though