public function testGetByNestingLevel() { // existed nested node $result = TreeUtils::getByNestingLevel(self::getTestGroup(), 2); $this->assertEquals(2, $result->getLevel()); $this->assertEquals('node2', $result->getName()); // not found node $result = TreeUtils::getByNestingLevel(self::getTestGroup(), 5); $this->assertNull($result); }
/** * {@inheritdoc} */ public function chooseActiveGroups($activeGroup, $activeSubGroup) { $tree = $this->getTree(); if ($activeGroup === null) { $activeGroup = TreeUtils::getFirstNodeName($tree); } // we can find active subgroup only in case if group is specified if ($activeSubGroup === null && $activeGroup) { $subtree = TreeUtils::findNodeByName($tree, $activeGroup); if ($subtree instanceof GroupNodeDefinition) { $subGroups = TreeUtils::getByNestingLevel($subtree, 2); if ($subGroups instanceof GroupNodeDefinition) { $activeSubGroup = TreeUtils::getFirstNodeName($subGroups); } } } return array($activeGroup, $activeSubGroup); }