[FLOW3-general] Abstract classes and extending objects

Zach Davis zach at castironcoding.com
Thu Aug 18 01:11:42 CEST 2011


I'm not positive this is what you're trying to do, but this worked for me:

/**
  * @scope prototype
  * @entity
  * @InheritanceType("SINGLE_TABLE")
  * @DiscriminatorColumn(name="type", type="string")
  * @DiscriminatorMap({"AccountIndividual" = "AccountIndividual", 
"AccountOrganization" = "AccountOrganization"})
  */
class Account {
}

/**
  * @scope prototype
  * @entity
  */
class AccountIndividual extends Account {
}

/**
  * @scope prototype
  * @entity
  */
class AccountOrganization extends Account {
}

With these annotations, Doctrine seems to be able to store both types in 
the same table (and they also both get stored in the same repository, 
which was useful for my purposes).

best,
Zach




Dawid Pacholczyk wrote:
> Hello List,
> I want to talk about one thing.
>
> For example I have 2 objects:
> -> Soldier
> -> Salesman
>
> They are diffrent persons but they have something in common like name,
> surname, age etc
>
> but also some diffrent thing like for example Soldier have a rank or
> Salesman got salary
>
> Now I would like to create ABSTRACT class Person and create normal
> classes Soldier and Salesman that will extend Person. How can I do that ?
>
> Should I just create normal models (but one as abstract class) and use
> standard adnotations to map object ? How can I extend an object via
> doctrine ?
>
> Best regards,
> Dawid Pacholczyk


More information about the FLOW3-general mailing list