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.

57 rindas
2.1KB

  1. <?php
  2. namespace Lc\ShopBundle\Controller\Backend;
  3. use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
  4. use Lc\ShopBundle\Form\Backend\Common\ReminderType;
  5. use Symfony\Component\HttpFoundation\Response;
  6. class ReminderController extends AdminController
  7. {
  8. public function renderTemplate($actionName, $templatePath, array $parameters = [])
  9. {
  10. if($this->request->isXmlHttpRequest() && ($actionName == 'new' || $actionName == 'edit')) {
  11. $response['flashMessages'] = $this->utils->getFlashMessages();
  12. $response['data'] = $this->render('@LcShop/backend/default/modal/edit_reminder.twig', $parameters)->getContent();
  13. return new Response(json_encode($response));
  14. }else{
  15. return parent::renderTemplate($actionName, $templatePath, $parameters);
  16. }
  17. }
  18. protected function redirectToReferrer(){
  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. }
  31. }
  32. public function setReminderDoneAction(){
  33. $id = $this->request->query->get('id');
  34. $done = $this->request->query->get('done');
  35. dump($done);
  36. $easyadmin = $this->request->attributes->get('easyadmin');
  37. $reminder = $easyadmin['item'];
  38. $reminder->setDone(true);
  39. $this->em->persist($reminder);
  40. $this->em->flush();
  41. return $this->redirectToReferrer();
  42. }
  43. }