您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

59 行
2.2KB

  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. }