示例#1
0
 public function getHighlights(SportGroup $g = null, $rootAbbr = null, $published = true)
 {
     try {
         $qb = $this->wallDao->createQueryBuilder("w");
         if ($g !== null) {
             $qb->join('w.groups', 'g')->where('g.id = :gid')->setParameter("gid", $g->getId())->orWhere("g.abbr = :abbr")->setParameter("abbr", $rootAbbr);
         }
         if ($published !== null) {
             $qb->andWhere("w.status = :status")->setParameter("status", WallPostStatus::PUBLISHED);
         }
         $qb->andWhere("w.highlight = true")->orderBy("w.title", "ASC");
         return $qb->getQuery()->getResult();
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
示例#2
0
 public function updateSportGroup(SportGroup $g)
 {
     if ($g == null) {
         throw new Exceptions\NullPointerException("Argument SportGroup cannot be null", 0);
     }
     try {
         $this->entityManager->beginTransaction();
         $dbGroup = $this->getSportGroup($g->getId(), false);
         if ($dbGroup !== null) {
             $dbGroup->fromArray($g->toArray());
             $this->groupParentHandle($dbGroup);
             $this->groupSportTypeHandle($dbGroup);
             $this->entityManager->merge($dbGroup);
             $this->entityManager->flush();
         }
         $this->entityManager->commit();
         $this->invalidateEntityCache($dbGroup);
         $this->onUpdate(clone $dbGroup);
     } catch (DuplicateEntryException $ex) {
         $this->logWarning($ex);
         throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     } catch (Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
示例#3
0
 public function getUniquePosition(User $u, SportGroup $g, Role $r)
 {
     try {
         $qb = $this->positionDao->createQueryBuilder("p")->where("p.owner = :owner")->andWhere("p.group = :group")->andWhere("p.role = :role")->setParameters(["owner" => $u->getId(), "group" => $g->getId(), "role" => $r->getId()]);
         return $qb->getQuery()->getSingleResult();
     } catch (\Doctrine\ORM\NoResultException $ex) {
         $this->logError($ex);
         throw new Exceptions\NoResultException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     } catch (\Exception $ex) {
         $this->logError($ex);
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
示例#4
0
 public function getGroupStaticPages(SportGroup $g)
 {
     try {
         $q = $this->pageDao->createQueryBuilder("sp")->where("sp.group = :group")->setParameter("group", $g->getId())->getQuery();
         return $q->getResult();
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
示例#5
0
 public function getTaxSeason(Season $s, SportGroup $sg)
 {
     try {
         $id = "{$this->getEntityClassName()}\\{$s->getId()}-{$sg->getId()}";
         $cache = $this->getEntityCache();
         $data = $cache->load($id);
         if (empty($data)) {
             $data = $this->taxDao->createQueryBuilder("t")->where("t.season = :season")->setParameter("season", $s->getId())->andWhere("t.sportGroup = :group")->setParameter("group", $sg->getId())->getQuery()->getSingleResult();
             $opts = [Cache::TAGS => [self::ENTITY_COLLECTION, $id]];
             $cache->save($id, $data, $opts);
         }
         return $data;
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }