Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

57 lines
1.9KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Reminder;
  3. use Lc\SovBundle\Controller\AbstractAdminController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. abstract class ReminderAdminController extends AbstractAdminController
  6. {
  7. public function renderTemplate($actionName, $templatePath, array $parameters = [])
  8. {
  9. if ($this->request->isXmlHttpRequest() && ($actionName == 'new' || $actionName == 'edit')) {
  10. $response['flashMessages'] = $this->utils->getFlashMessages();
  11. $response['data'] = $this->render('@LcShop/backend/default/modal/edit_reminder.twig', $parameters)->getContent();
  12. return new Response(json_encode($response));
  13. } else {
  14. return parent::renderTemplate($actionName, $templatePath, $parameters);
  15. }
  16. }
  17. protected function redirectToReferrer()
  18. {
  19. $action = $this->request->query->get('action');
  20. if ($action == 'new') {
  21. $this->utils->addFlash('success', 'success.reminder.add');
  22. } elseif ($action == 'edit') {
  23. $this->utils->addFlash('success', 'success.reminder.edit');
  24. } elseif ($action == ' setReminderDone') {
  25. $this->utils->addFlash('success', 'success.reminder.done');
  26. }
  27. if ($this->request->isXmlHttpRequest()) {
  28. $response['flashMessages'] = $this->utils->getFlashMessages();
  29. return new Response(json_encode($response));
  30. } else {
  31. return parent::redirectToReferrer();
  32. }
  33. }
  34. public function setReminderDoneAction()
  35. {
  36. $id = $this->request->query->get('id');
  37. $done = $this->request->query->get('done');
  38. $easyadmin = $this->request->attributes->get('easyadmin');
  39. $reminder = $easyadmin['item'];
  40. $reminder->setDone($done);
  41. $this->em->persist($reminder);
  42. $this->em->flush();
  43. return $this->redirectToReferrer();
  44. }
  45. }