コード例 #1
0
ファイル: UpdateTopicController.php プロジェクト: nabelhm/api
 /**
  * @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());
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: DeleteTopicController.php プロジェクト: nabelhm/api
 /**
  * @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());
 }
コード例 #4
0
 /**
  * @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"'));
 }
コード例 #5
0
 /**
  * @Req\Route("/info-sms/collect-topics")
  * @Req\Method({"GET"})
  *
  * @return JsonResponse
  */
 public function collectAction()
 {
     return new JsonResponse($this->collectTopicsApiWorker->collect());
 }