public function updateSportGroup(ArrayHash $values) { $type = new SportGroup(); $type->fromArray((array) $values); try { $this->sportGroupService->updateSportGroup($type); } catch (Exceptions\DataErrorException $ex) { $this->handleDataSave($values->id, "this", $ex); } $this->redirect("default"); }
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()); } }
public function getArticles(SportGroup $g = null, $limit = 20) { try { if (is_null($g)) { return $this->articleDao->createQueryBuilder("a")->andWhere("a.status = :state")->setParameter("state", ArticleStatus::PUBLISHED)->getQuery()->getResult(); } $id = SportGroup::getClassName() . "-" . $g->getId(); $cache = $this->getEntityCache(); $data = $cache->load($id); if ($data === null) { $qb = $this->articleDao->createQueryBuilder("a")->innerJoin('a.groups', 'g')->where('g.id = :gid')->setParameter("gid", $g->id)->andWhere("a.status = :state")->setParameter("state", ArticleStatus::PUBLISHED)->orderBy("a.updated", "DESC")->setMaxResults($limit); $data = $qb->getQuery()->getResult(); $opts = [Cache::TAGS => [self::ENTITY_COLLECTION, $id, self::SELECT_COLLECTION]]; $cache->save($id, $data, $opts); } return $data; } catch (\Doctrine\ORM\NoResultException $ex) { $this->logWarning($ex->getMessage()); throw new Exceptions\DataErrorException("No relations article -> group {$g} found"); } catch (\Exception $ex) { $this->logError($ex->getMessage()); throw new Exceptions\DataErrorException("Error reading articles according to related group {$g}"); } }
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()); } }
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()); } }
public function getPositionsWithinGroup(SportGroup $g, $useCache = true) { try { $qb = $this->positionDao->createQueryBuilder(); $qb->select("p")->from("App\\Model\\Entities\\Position", "p")->where("p.group = :group")->setParameter("group", $g); $q = $qb->getQuery(); if (!$useCache) { return $q->getResult(); } $id = User::getClassName() . "in" . SportGroup::getClassName() . "-" . $g->getId(); $cache = $this->getEntityCache(); $data = $cache->load($id); if ($data == null) { $data = $q->getResult(); $opts = [Cache::TAGS => [self::ENTITY_COLLECTION, self::STRANGER_COLLECTION, $id], Cache::SLIDING => true]; $cache->save($id, $data, $opts); } return $data; } catch (\Exception $e) { $this->logError($e); throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious()); } }
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()); } }