Symfony Doctrine 嵌套设置根查询的路径

发布于 2024-08-31 17:13:18 字数 81 浏览 4 评论 0原文

symfony中有没有一种方法可以从嵌套的学说集获取从 id 元素指定到 Doctrine_Collection 或数组中的根元素的整个路径/路由?

Is there a way in symfony to get from a doctrine nested set the whole path/route from a specified by id element to the root element in a Doctrine_Collection or array ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一场信仰旅途 2024-09-07 17:13:18

我认为这应该返回您所追求的内容:

$obj->getNode()->getAncestors();

来自 文档

I think this should return what you are after:

$obj->getNode()->getAncestors();

From the docs

离笑几人歌 2024-09-07 17:13:18

如果您正在考虑构建类似面包屑路径的东西,getPath 会做到这一点:

getPath
public string getPath(string seperator, mixed includeRecord, bool includeNode)

gets path to node from root, uses record::toString() method to get node names

Parameters:
    seperator - path seperator
    includeNode - whether or not to include node at end of path
Returns:
    string representation of path

http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_node_nestedset.html#getPath%28%29

所以你需要重写 __toString()在你的模型中。如果不这样做,Doctrine 会通过查找名为“名称”、“标题”等的列来尝试猜测要写什么。

If you're thinking of building something like a breadcrumb trail, getPath would do it:

getPath
public string getPath(string seperator, mixed includeRecord, bool includeNode)

gets path to node from root, uses record::toString() method to get node names

Parameters:
    seperator - path seperator
    includeNode - whether or not to include node at end of path
Returns:
    string representation of path

http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_node_nestedset.html#getPath%28%29

So you need to override __toString() in your model. If you don't, Doctrine will try to guess what to write by looking for columns called "name", "title" and the like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文