Skip to content

Conversation

@simesy
Copy link
Contributor

@simesy simesy commented Feb 22, 2021

Without disturbing the existing $depth parameter, this provides an additional $start parameter. This is useful for those wanting to process a tree in layers (say building a visual representation), or if there is meaning to a specific layer, without doing a lot of php processing of the result set.

With the tree used in the tests, you can for example take 1 depth starting at depth 2.

                    (1)       <-----------------------------+
                   1 | 22                          Root node.
                     |
            ————————————————————————
           (2)                    (3)
          2 | 9                 10 | 21
            |                      |
            |                      |
    —————————          ————————————————————
   (4)                (7)       (8)      (9)     <----------+
  3 | 8             11 | 16    17 18    19 20       $depth 1.
    |                  |                            $start 2.
    |                  |
 ————————         ———————————
(5)    (6)      (10)       (11)
4 5    6 7     12  13     14  15

Closes #23

* The nested array of descendants.
*/
public function findDescendants(NodeKey $nodeKey, $depth = 0);
public function findDescendants(NodeKey $nodeKey, $depth = 0, $start = 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this defaults to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it should be 1. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the fix.

Copy link
Member

@larowlan larowlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me


/**
* Loads the test data.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@kimpepper kimpepper merged commit 3406247 into previousnext:master Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to find descendents at a certain depth.

3 participants