Skip to content

Commit bb67a63

Browse files
committed
Update readme to follow api
1 parent a4488db commit bb67a63

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

README.markdown

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ There are few more methods:
142142
* `nextSiblings()` and `prevSiblings()` to query nodes after and before the node
143143
respectively.
144144

145+
`Node` is provided with few helper methods for quicker access:
146+
147+
* `getAncestors`
148+
* `getDescendants`
149+
* `getSiblings`
150+
* `getNextSiblings`
151+
* `getPrevSiblings`
152+
* `getNextSibling`
153+
* `getPrevSibling`
154+
155+
Each of this methods accepts array of columns needed to be selected and returns
156+
the result of corresponding query.
157+
145158
Nodes can be provided with _nesting level_ if scope `withDepth` is applied:
146159

147160
```php
@@ -189,7 +202,7 @@ the parent.
189202
To move node down, this snippet can be used:
190203

191204
```php
192-
if ($sibling = $node->nextSiblings()->first())
205+
if ($sibling = $node->getNextSibling())
193206
{
194207
$node->after($sibling)->save();
195208
}
@@ -198,7 +211,7 @@ if ($sibling = $node->nextSiblings()->first())
198211
Moving up is similar:
199212

200213
```php
201-
if ($sibling = $node->prevSiblings()->first())
214+
if ($sibling = $node->getPrevSibling())
202215
{
203216
$node->before($sibling)->save();
204217
}

src/Kalnoy/Nestedset/Node.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,18 @@ public function getDescendants(array $columns = array('*'))
759759
return $this->descendants()->get($columns);
760760
}
761761

762+
/**
763+
* Shorthand for siblings()
764+
*
765+
* @param array $column
766+
*
767+
* @return \Kalnoy\Nestedset\Collection
768+
*/
769+
public function getSiblings(array $column = array('*'))
770+
{
771+
return $this->siblings()->get($columns);
772+
}
773+
762774
/**
763775
* Shorthand for nextSiblings().
764776
*

0 commit comments

Comments
 (0)