简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM