Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ReminderController.php 1.9KB

pirms 3 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Lc\SovBundle\Controller\Reminder;
  3. use Lc\SovBundle\Controller\AbstractAdminController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. abstract class ReminderController 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. }