You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
преди 4 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. }else{
  31. return parent::redirectToReferrer();
  32. }
  33. }
  34. public function setReminderDoneAction(){
  35. $id = $this->request->query->get('id');
  36. $done = $this->request->query->get('done');
  37. $easyadmin = $this->request->attributes->get('easyadmin');
  38. $reminder = $easyadmin['item'];
  39. $reminder->setDone($done);
  40. $this->em->persist($reminder);
  41. $this->em->flush();
  42. return $this->redirectToReferrer();
  43. }
  44. }