private function _mapByTeams($tree) { $req = new DownlineMapTreeByTeamsRequest(); $req->setAsCustomerId(Compress::ATTR_CUSTOMER_ID); $req->setAsParentId(Compress::ATTR_PARENT_ID); $req->setDataToMap($tree); $resp = $this->_callDownlineMap->treeByTeams($req); return $resp->getMapped(); }
public function treeByTeams(Map\Request\TreeByTeams $req) { $result = new Response\TreeByTeams(); /* extract parameters from request */ $keyCustId = $req->getAsCustomerId(); $keyParentId = $req->getAsParentId(); $toMap = $req->getDataToMap(); $mapped = []; foreach ($toMap as $item) { $custId = $item[$keyCustId]; $parentId = $item[$keyParentId]; if ($custId == $parentId) { /* skip root nodes, root node is not a member of a team. */ continue; } if (!isset($mapped[$parentId])) { $mapped[$parentId] = []; } $mapped[$parentId][] = $custId; } $result->setMapped($mapped); $result->markSucceed(); return $result; }