Beispiel #1
0
 public function getSelectUsers($id = null, $active = true)
 {
     if (!is_bool($active) && !is_null($active)) {
         throw new Exceptions\InvalidArgumentException("Argument active has to be type of boolean or null, '{$active}' given");
     }
     $cache = $this->getEntityCache();
     $data = $cache->load(self::SELECT_COLLECTION);
     try {
         if ($data === null) {
             $data = [];
             $all = $this->userDao->findAll(["active" => $active]);
             foreach ($all as $u) {
                 if (!is_null($active) && $active !== $u->getActive()) {
                     continue;
                 }
                 $data = $data + [$u->getId() => $u->getName() . " " . $u->getSurname() . " (" . $u->getId() . ")"];
             }
             $opt = [Cache::TAGS => [self::SELECT_COLLECTION]];
             $cache->save(self::SELECT_COLLECTION, $data, $opt);
         }
         if ($id != null) {
             unset($data[$id]);
         }
         return $data;
     } catch (\Exception $e) {
         throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
 }
Beispiel #2
0
 public function getComments()
 {
     try {
         return $this->commentDao->findAll();
     } catch (\Exception $ex) {
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
Beispiel #3
0
 public function getForums(SportGroup $g)
 {
     try {
         if ($g == null) {
             return $this->forumDao->findAll();
         }
         $qb = $this->entityManager->createQueryBuilder();
         $qb->select('f')->from('App\\Model\\Entities\\Forum', 'f')->join('f.groups', 'g')->where('g.id = :gid')->setParameter("gid", $g->id);
         return $qb->getQuery()->getResult();
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
Beispiel #4
0
 public function getRules()
 {
     $cache = $this->getEntityCache();
     $data = $cache->load(self::ENTITY_COLLECTION);
     try {
         if ($data === null) {
             $data = $this->aclRuleDao->findAll();
             $opt = [Cache::TAGS => [self::ENTITY_COLLECTION], Cache::SLIDING => true];
             $cache->save(self::ENTITY_COLLECTION, $data, $opt);
         }
     } catch (\Exception $e) {
         $this->logError($e);
         throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
     return $data;
 }
Beispiel #5
0
 public function getAllSportGroups($root = null, $active = null)
 {
     if ($active !== null && !is_bool($active)) {
         throw new Exceptions\InvalidArgumentException("Argument active has to be type of bool, '{$active}' given");
     }
     try {
         if ($root !== null) {
             $qb = $this->entityManager->createQueryBuilder();
             $qb = $qb->select("g")->from("App\\Model\\Entities\\SportGroup", "g")->where("g.parent = :parent");
             if ($active !== null) {
                 $qb = $qb->andWhere("g.activity = :act")->setParameter("act", $active);
             }
             $qb = $qb->orderBy("ASC", "g.priority, g.name")->setParameter("parent", $root);
             return $qb->getQuery()->getResult();
         }
         return $this->groupDao->findAll();
     } catch (\Exceptions $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
Beispiel #6
0
 /**
  * @return User[]
  */
 public function getUsersList()
 {
     return $this->userDao->findAll();
 }