Esempio n. 1
0
 /**
  * @inheritDoc
  */
 public function processPostPublish(GamePostPublishRequest $request) : Game
 {
     $user = $this->container->get("core.handler.user")->getSecureUser($request);
     try {
         $game = $this->repository->find($request->getId());
     } catch (GameNotFoundException $e) {
         $this->getRequestError()->addError("id", "Game is not found")->throwException(ResponseStatusCode::NOT_FOUND);
     }
     /** @var Game $game */
     $gamePublishEvent = new GamePublishEvent();
     $gamePublishEvent->setGame($game);
     $gamePublishEvent->setUser($user);
     switch (true) {
         case !empty($request->getFen()):
             $this->container->get("event_dispatcher")->dispatch(GameEvents::PUBLISH_FEN, $gamePublishEvent->setFen($request->getFen()));
             break;
         case !empty($request->getPgn()):
             $this->container->get("event_dispatcher")->dispatch(GameEvents::PUBLISH_PGN, $gamePublishEvent->setPgn($request->getPgn()));
             break;
     }
     return $game;
 }
 /**
  * @param GamePublishEvent $event
  */
 public function onGamePublishPgn(GamePublishEvent $event)
 {
     $this->container->get("immortalchessnet.service.publish")->publishNewPost(new Post($this->container->getParameter("app_immortalchess.forum_playzone"), self::THREAD_WITH_INTERESTING_GAMES, $event->getUser()->getLogin(), $this->container->getParameter("app_immortalchess.post_userid_for_calls"), "Партия " . $event->getGame()->getUserWhite() . "-" . $event->getGame()->getUserBlack(), $this->container->get("templating")->render('Post/gamepgn.html.twig', ['game' => $event->getGame(), 'pgn' => $event->getPgn()])));
 }