Esempio n. 1
0
 public function updateSeasonHandle(ArrayHash $values)
 {
     $season = new Season((array) $values);
     try {
         $season->setEditor($this->getUser()->getIdentity());
         $this->getSeasonService()->updateSeason($season);
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataSave($season->getId(), "this", $ex);
     }
     $this->redirect("default");
 }
Esempio n. 2
0
 public function updateSeason(Season $s)
 {
     if ($s === null) {
         throw new Exceptions\NullPointerException("Argument Season cannot be null");
     }
     try {
         $this->entityManager->beginTransaction();
         $seasonDb = $this->seasonDao->find($s->getId(), false);
         if ($seasonDb !== null) {
             if ($s->getCurrent()) {
                 $this->setAllSeasonsAsInactive();
             }
             $seasonDb->fromArray($s->toArray());
             $this->seasonEditorTypeHandle($seasonDb);
             $this->entityManager->merge($seasonDb);
             $this->entityManager->flush();
         }
         $this->entityManager->commit();
         $this->invalidateEntityCache($seasonDb);
         $this->onUpdate($s);
     } catch (DuplicateEntryException $ex) {
         $this->logWarning($ex);
         throw new Exceptions\DuplicateEntryException($ex->getMessage(), Exceptions\DuplicateEntryException::SEASON_LABEL, $ex->getPrevious());
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
 public function getUsersApplication(User $u, Season $s)
 {
     try {
         $id = "{$this->getEntityClassName()}/{$u->getId()}-{$s->getId()}";
         $cache = $this->getEntityCache();
         $data = $cache->load($id);
         if ($data === null) {
             $data = $this->seasonApplicationDao->createQueryBuilder("a")->where("a.owner = :owner")->setParameter("owner", $u->getId())->andWhere("a.season = :season")->setParameter("season", $s->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());
     }
 }
Esempio n. 4
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());
     }
 }