private function prepareTreeData() { $res = []; try { $sportTypes = $this->sportTypeService->getAllSportTypes(true, true); $groups = $this->sportGroupService->getAllSportGroups(null, true); $rootArray = array_filter($groups, function ($e) { if ($e->getParent() == null) { return true; } return false; }); if (!empty($rootArray)) { $rootGroup = $rootArray[0]; foreach ($sportTypes as $type) { $typeGroups = array_filter($groups, function ($e) use($type) { if ($e->getSportType() != null && $e->getSportType()->getId() == $type->getId()) { return true; } return false; }); array_push($res, [PMC::TYPE_ID => $type, PMC::GROUPS_ID => $typeGroups, PMC::ROOT_ID => $rootGroup]); } } } catch (Exceptions\DataErrorException $ex) { $this->logError($ex); throw new Exceptions\InvalidStateException("COMPONENT PublicMenu could not be inicialized - {$ex->getMessage()}", $ex->getCode(), $ex->getPrevious()); } return $res; }