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;
 }
示例#2
0
 private function prepareSportGroupForm($name, $selfId = null)
 {
     $form = new SportGroupForm($this, $name, $this->getTranslator());
     $form->setPriorities($this->sportGroupService->getPriorities());
     try {
         $sportGroups = $this->sportGroupService->getSelectAllSportGroups($selfId);
         $form->setSportGroups($sportGroups);
         $sportTypes = $this->sportTypeService->getSelectSportTypes();
         $form->setSportTypes($sportTypes);
     } catch (Exceptions\DataErrorException $ex) {
         $this->flashMessage($ex->getMessage(), self::FM_ERROR);
     }
     return $form;
 }