Пример #1
0
 public function getGroups()
 {
     if (!isset($this->groups)) {
         try {
             $this->groups = $this->groupsService->getAllSportGroups();
         } catch (Exceptions\DataErrorException $ex) {
             $this->logError($ex->getMessage);
             throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
         }
     }
     return $this->groups;
 }
Пример #2
0
 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;
 }
Пример #3
0
 protected function createComponentContactsGroupsMenu($name)
 {
     $c = new \App\Components\MenuControl($this, $name);
     $c->setLabel("securityModule.public.contacts.groupsMenu");
     $groups = $this->sportGroupService->getAllSportGroups(null, true);
     $gid = $this->getParameter("gid");
     foreach ($groups as $g) {
         $id = null;
         if (is_numeric($gid)) {
             $id = $g->getId();
         } else {
             $id = $g->getAbbr();
         }
         $name = $g->getSportType() !== null ? "{$g->getName()} ({$g->getSportType()->getName()})" : "{$g->getName()}";
         $node = $c->addNode($name, ":Security:Public:default", null, ["param" => $id]);
         if ($id == $gid || ($gid == self::ROOT_GROUP || $gid === null) && $id == self::ROOT_GROUP) {
             $c->setCurrentNode($node);
         }
     }
     return $c;
 }
Пример #4
0
 protected function createComponentStaticPagesGroupsMenu($name)
 {
     $c = new \App\Components\MenuControl($this, $name);
     $c->setLabel("systemModule.publicPages.groupsMenu");
     $groups = $this->sportGroupService->getAllSportGroups(null, true);
     $currentAbbr = null;
     $e = $this->getEntity();
     if ($this->getEntity() instanceof SportGroup) {
         $currentAbbr = $e->getAbbr();
     } elseif ($e instanceof StaticPage) {
         $currentAbbr = $e->getGroup()->getAbbr();
     }
     foreach ($groups as $g) {
         $abbr = $g->getAbbr();
         //if (!$g->getStaticPages()->isEmpty()) {
         $node = $c->addNode($g->getName(), "showGroupPages", true, ["param" => $abbr]);
         if ($currentAbbr == $abbr) {
             $c->setCurrentNode($node);
         }
         //}
     }
     return $c;
 }