/** * @Req\Route("/info-sms/update-topic/{id}") * @Req\Method({"POST"}) * * @param string $id * @param Request $request * * @return JsonResponse */ public function updateAction($id, Request $request) { $data = $request->request->all(); foreach (array('title', 'description', 'average', 'active', 'order') as $key) { Assertion::keyExists($data, $key); } $this->updateTopicApiWorker->update($id, $data['title'], $data['description'], $data['average'], $data['active'], $data['order']); return new JsonResponse($this->collectTopicsApiWorker->collect()); }
/** * Collects latest stats grouped by topic. */ public function collect() { $topics = $this->collectTopicsApiWorker->collect(); $stats = []; foreach ($topics as $topic) { $stats = array_merge($stats, iterator_to_array($this->connectToStorageInternalWorker->connect()->find(['topics' => $topic['id']])->fields(['_id' => 0])->sort(['_id' => -1])->limit(5))); } return $stats; }
/** * @Req\Route("/info-sms/delete-topic/{id}") * @Req\Method({"POST"}) * * @param string $id * * @return JsonResponse */ public function deleteAction($id) { $this->deleteTopicApiWorker->delete($id); return new JsonResponse($this->collectTopicsApiWorker->collect()); }
/** * @Req\Route("/info-sms/message/generate-latest-stats") * @Req\Method({"GET"}) * * @return JsonResponse */ public function generateAction() { $html = $this->templateEngine->render("@MuchacubaModel/InfoSms\\Message\\GenerateLatestStatsGroupedByTopic\\generate.html.twig", ['topics' => $this->collectTopicsApiWorker->collect(), 'stats' => $this->collectLatestStatsGroupedByTopic->collect()]); return new Response($this->pdfGenerator->getOutputFromHtml($html), 200, array('Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="ultimas-noticias.pdf"')); }
/** * @Req\Route("/info-sms/collect-topics") * @Req\Method({"GET"}) * * @return JsonResponse */ public function collectAction() { return new JsonResponse($this->collectTopicsApiWorker->collect()); }