Exemplo n.º 1
0
 /**
  * @Template
  *
  * @return array
  */
 public function homeAction()
 {
     $this->sessionProvider->clear();
     $topFetchers = $this->userRepository->getTopFetchers();
     $topReceivers = $this->userRepository->getTopReceivers();
     $topQuestionResults = $this->userRepository->getTopQuestionResults();
     return ['topFetchers' => $topFetchers, 'topReceivers' => $topReceivers, 'topQuestionResults' => $topQuestionResults];
 }
Exemplo n.º 2
0
 /**
  * @Template
  *
  * @param Request $request
  * @return array
  */
 public function consumptionAction(Request $request)
 {
     /** @var User $currentUser */
     $currentUser = $this->entityManager->merge($this->loginUser->getUser());
     $users = $this->userRepository->findAllExceptUser($currentUser);
     $receiverId = $request->query->get('receiver_id');
     $receiver = $this->userRepository->findOneById($receiverId);
     if ($receiver) {
         $consumption = new Consumption($currentUser, $receiver);
         $this->entityManager->persist($consumption);
         $this->entityManager->flush();
         return new RedirectResponse($this->urlGenerator->generate('question_detail', ['id' => $this->questionRepository->findOneRandom()->getId()]));
     }
     return ['users' => $users];
 }