Closed mkevenaar closed 10 years ago
Will this work?
if ($relation->getStartNode()->getId() == $node->getId()) {
// $relation is outgoing from $node
} else {
// $relation is incoming to $node
}
that would work for now.
are you going to add this functionality in the Relationship object?
No. Asking for $relationship->direction
doesn't make sense, because the answer changes depending on context, i. e. you can only ask what direction a relationship is from a specific node. A relationship doesn't have direction on it's own, so asking the relationship for its direction is meaningless.
If you want to know what direction a relationship is from a specific node, the only way to do that is to compare the node to either the start or end node of the relationship.
What problem are you trying to solve? Maybe there is another way to do it.
It would be nice to be able to know in a Relationship object what the direction of this relationship is.
Example: