AlexK
AlexK

Reputation: 469

Symfony2 Doctrine NestedTree different Entity Types

I'm currently searching for a solution for this Problem: I have a nested Tree, but the Leafs can be different types of Entities. For Example I have a Entity "Project", with children that can be of the type "Folder" or "Textfile", Folders having the possibility to have Children of their own again.

Since i couldn't find a solution: Is there a native Solution for this Problem (like using an Abstract Entity or Interface) or how would you solve this Problem?

Thanks in advance!

Upvotes: 0

Views: 226

Answers (1)

Flask
Flask

Reputation: 4996

I dont see a proper solution with inheritance here, since the entities differ from each other.

What could be a solution; having a separate tree of lets call it items, and the items have an one-to-one relation to either project, folder or textfile. Furthermore you could build a proxy-like manager which allows you to call ->getObject() on the item.

Upvotes: 1

Related Questions