I found the following example in the doctrine documentation where they have added mapping to a trait:
/**
* Trait class
*/
trait ExampleTrait
{
/** @Id @Column(type="string") */
private $id;
/**
* @Column(name="trait_foo", type="integer", length=100, nullable=true, unique=true)
*/
protected $foo;
/**
* @OneToOne(targetEntity="Bar", cascade={"persist", "merge"})
* @JoinColumn(name="example_trait_bar_id", referencedColumnName="id")
*/
protected $bar;
}
I am trying to map a trait without having to duplicate the mapping in the classes that inherit it. I haven't honestly tried this above as my current project is using yaml for mapping but it looks like a regular php class would inherit the mapping as well when using the trait.
Is there a way to inherit the mapping for this trait without using associations but using yaml or xml instead? I tried setting the trait as a mapped superclass but it didn't work but I am basically looking for the same type of idea.
Thanks.