简体   繁体   English

如何在 symfony 中使用学说实现嵌套树列表

[英]How to implements Nested tree list with doctrine in symfony

I need a Nested tree in my project build on Symfony3 with doctrine.我的项目中需要一个基于 Symfony3 和学说的嵌套树。 I read this article - link .我读了这篇文章 - 链接 I understand how it works, but I'm a beginner in symfony and doctrine.我理解它是如何工作的,但我是 symfony 和学说的初学者。 So my question is how to implements this in symfony.所以我的问题是如何在 symfony 中实现这一点。 I've searched for an bundle, which can provide that, but I didn't find any.我搜索了一个可以提供的包,但我没有找到。

My first though was that I will create an entity a than in Controller do what I need (with SQL statemens in doctrine).我的第一个想法是我将创建一个实体 a 而不是在 Controller 中做我需要的事情(在学说中使用 SQL 语句)。 But I know that it is really bad practice.但我知道这是非常糟糕的做法。

So where to store which code?那么在哪里存储哪些代码呢? Should I have entity with functions like insertNode, deleteNode (with SQL in it)?我是否应该拥有具有 insertNode、deleteNode 等功能的实体(其中包含 SQL)?

Thanks for advice for best practice on this.感谢您提供有关此方面最佳实践的建议。

您需要Doctrine Extensions Bundle的 Tree 功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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