gpt4 book ai didi

symfony - 学说 2 树扩展 : Closure Table

转载 作者:行者123 更新时间:2023-12-01 02:10:17 25 4
gpt4 key购买 nike

我正在为 Doctrine 2 和 Closure Table Strategy 使用 Tree - Nestedset 行为扩展。在我的网站上,用户可以创建文件夹和子文件夹并查看它们。我通过使用 Closure Table 策略实现了这一点,并使用 渲染文件夹。 childrenHierarchy() 方法:

       $directoryTree = $repository->childrenHierarchy(
null,
true,
array(
'decorate' => false,
'childSort' => array('field' => 'directory_name', 'dir' => 'asc')
));

它工作正常,但它返回所有用户的所有文件夹,我不知道如何定义 用户 ID 在这种情况下,仅呈现属于登录用户的文件夹。有没有办法做到这一点?

我会很高兴你的回答。

最佳答案

来自 doc :

childrenHierarchy: This useful method allows you to build an array of nodes representing the hierarchy of a tree. Arguments: node: If you pass a node, the method will return its children. Defaults to "null" (this means it will return ALL nodes).



会是这样的:
// example, 
$loggedInUserFolder = SOME_METHOD_RETURNS_USER_FOLDER($this->getUser());
$directoryTree = $repository->childrenHierarchy(
$loggedInUserFolder,
true,
array(
'decorate' => false,
'childSort' => array('field' => 'directory_name', 'dir' => 'asc')
));

关于symfony - 学说 2 树扩展 : Closure Table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29979859/

25 4 0