コード例 #1
0
 public function newAction()
 {
     $request = $this->get('request');
     $form = $this->get('lichess.form.manager')->createHookForm();
     if ($request->getMethod() === 'POST') {
         $form->bindRequest($request);
         if ($form->isValid()) {
             $config = $form->getData();
             $hook = new Hook();
             $hook->fromArray($config->toArray());
             if ($this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
                 $hook->setUser($this->get('security.context')->getToken()->getUser());
             }
             $this->get('lichess.config.persistence')->saveConfigFor('hook', $config->toArray());
             $this->get('doctrine.odm.mongodb.document_manager')->persist($hook);
             $this->get('doctrine.odm.mongodb.document_manager')->flush();
             $this->get('lila')->lobbyCreate($hook->getOwnerId());
             return new RedirectResponse($this->generateUrl('lichess_hook', array('id' => $hook->getOwnerId())));
         } else {
             return new RedirectResponse($this->generateUrl('lichess_homepage'));
         }
     } elseif (!$request->isXmlHttpRequest() && $this->container->getParameter('kernel.environment') !== 'test') {
         return new RedirectResponse($this->generateUrl('lichess_homepage') . '#hook');
     }
     $response = $this->get('lichess.provider')->uncachableResponse();
     return $this->render('LichessOpeningBundle:Config:hook.html.twig', array('form' => $form->createView(), 'config' => $form->getData()), $response);
 }
コード例 #2
0
ファイル: Logger.php プロジェクト: hotfics/lichess-old
 public function expandHook(Hook $hook)
 {
     return sprintf('hook(%s,%s,%s,%s)', $hook->getOwnerId(), $hook->getUsername(), $hook->getVariant(), $hook->getMode() ? 'rated' : 'casual');
 }
コード例 #3
0
ファイル: Memory.php プロジェクト: hafeez3000/lichess
 public function isAlive(Hook $hook)
 {
     return (bool) apc_fetch($this->getHookKey($hook->getOwnerId()));
 }