{"action":"closed","issue":{"url":"https://api.github.com/repos/Atlantic18/DoctrineExtensions/issues/1517","labels_url":"https://api.github.com/repos/Atlantic18/DoctrineExtensions/issues/1517/labels{/name}","comments_url":"https://api.github.com/repos/Atlantic18/DoctrineExtensions/issues/1517/comments","events_url":"https://api.github.com/repos/Atlantic18/DoctrineExtensions/issues/1517/events","html_url":"https://github.com/Atlantic18/DoctrineExtensions/issues/1517","id":130608451,"number":1517,"title":"how to get children/ancestors till particular level or at particular level?","user":{"login":"vishalmelmatti","id":1233269,"avatar_url":"https://avatars.githubusercontent.com/u/1233269?v=3","gravatar_id":"","url":"https://api.github.com/users/vishalmelmatti","html_url":"https://github.com/vishalmelmatti","followers_url":"https://api.github.com/users/vishalmelmatti/followers","following_url":"https://api.github.com/users/vishalmelmatti/following{/other_user}","gists_url":"https://api.github.com/users/vishalmelmatti/gists{/gist_id}","starred_url":"https://api.github.com/users/vishalmelmatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vishalmelmatti/subscriptions","organizations_url":"https://api.github.com/users/vishalmelmatti/orgs","repos_url":"https://api.github.com/users/vishalmelmatti/repos","events_url":"https://api.github.com/users/vishalmelmatti/events{/privacy}","received_events_url":"https://api.github.com/users/vishalmelmatti/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-02T08:13:32Z","updated_at":"2016-02-02T12:14:30Z","closed_at":"2016-02-02T12:14:30Z","body":"I am using gedmo tree - closure strategy for hierarchical data. I have requirement where I want to fetch children/ancestors till particular level/depth. and at particular level. e.g.\r\n\r\nI have region hierarchy global regions -> region -> country -> city . \r\n\r\nFrom city I want to get \r\n\r\n1) its ancestors till regions. So it should return country <- region. \r\n2) I want to get only region in which city comes under. (at particular level)\r\n\r\nsame for children,\r\n\r\n1) If I have global region, I want to get all children till country. (no cities) - till particular depth\r\n\r\n2) If I have global region, I want to get all countries only which comes under global region. \r\n\r\nIn ClosureTreeRepository->childrenQueryBuilder I can see\r\n\r\n       if ($direct) {\r\n          $where .= 'c.depth = 1';\r\n       } else {\r\n          $where .= 'c.descendant <> :node';\r\n       }\r\n\r\nDepth is hard-coded to 1 for direct. So i can't pass depth from outside. To be able to pass from outside might help.\r\n\r\nThere is no way to get \"till depth\". Can anybody please help on achieving this.  "}}