0

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!

AlexK
  • 471
  • 1
  • 5
  • 14

1 Answers1

1

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.

Flask
  • 4,966
  • 1
  • 20
  • 39
  • Thanks, that's just what i feared... That was the first thing I wanted to try, but i could not find a way to Query the related Object from inside the Entity... I know there must be a way around that, but I couldn't find it... – AlexK Jul 30 '13 at 15:53