Search code examples
symfonydoctrine-ormcomposite

PHP Composite Design Pattern with Symfony2 and Doctrine


Is there any example for Composite Pattern with Doctrine? I mean PHP source code using Doctrine annotations.

I could find Decorator Pattern here : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/decorator-pattern.html but no luck about Composite Pattern.


Solution

  • You should be able to do this with Inheritance Mapping (see http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/inheritance-mapping.html) and just normal associations with the type you want (see http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/association-mapping.html)