Symfony Doctrine Nested Set Path To Root Query
Is there a way in symfony to get from a doctrine nested set the whole path/route from a s开发者_C百科pecified by id element to the root element in a Doctrine_Collection or array ?
I think this should return what you are after:
$obj->getNode()->getAncestors();
From the docs
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.
精彩评论