1

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 ?

2 Answers 2

2

I think this should return what you are after:

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

From the docs

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.