I've separated my models from my entities. I have three models with corresponding entities: Review, RatedReview, and ScoredReview. Their relationship is ScoredReview extends RatedReview extends Review.
So for my models I have:
// Project/ReviewBundle/Model/Review.php class Review { } // Project/ReviewBundle/Model/RatedReview.php class RatedReview extends Review { } // Project/ReviewBundle/Model/ScoredReview.php class ScoredReview extends RatedReview { } Then I implement the entities by extending the models, like so:
// Project/ReviewBundle/Entity/Review.php use Project\ReviewBundle\Model\Review as BaseReview; class Review extends BaseReview { } // Project/ReviewBundle/Entity/RatedReview.php use Project\ReviewBundle\Model\RatedReview as BaseRatedReview; class RatedReview extends BaseRatedReview { } // Project/ReviewBundle/Entity/ScoredReview.php use Project\ReviewBundle\Model\ScoredReview as BaseScoredReview; class ScoredReview extends BaseScoredReview { } So the inheritance is happening on the model side. Doctrine can't seem to see this, and maps them to separate tables. I understand this is because Doctrine only looks for entities extending other entities, not entities extending models.
Is there a better way for me to separate the models from the entities, while retaining the ability to extend entities? Is this where traits come in handy?
Put another way, is there anyway that I can have a tree made of models, and a tree made of entities that extends those models?