|
- <?php
-
- namespace Lc\SovBundle\Controller\Reminder;
-
- use Lc\SovBundle\Controller\AbstractAdminController;
- use Symfony\Component\HttpFoundation\Response;
-
- abstract class ReminderController extends AbstractAdminController
- {
-
- public function renderTemplate($actionName, $templatePath, array $parameters = [])
- {
- if ($this->request->isXmlHttpRequest() && ($actionName == 'new' || $actionName == 'edit')) {
- $response['flashMessages'] = $this->utils->getFlashMessages();
-
- $response['data'] = $this->render('@LcShop/backend/default/modal/edit_reminder.twig', $parameters)->getContent();
- return new Response(json_encode($response));
- } else {
- return parent::renderTemplate($actionName, $templatePath, $parameters);
- }
- }
-
- protected function redirectToReferrer()
- {
- $action = $this->request->query->get('action');
-
- if ($action == 'new') {
- $this->utils->addFlash('success', 'success.reminder.add');
- } elseif ($action == 'edit') {
- $this->utils->addFlash('success', 'success.reminder.edit');
- } elseif ($action == ' setReminderDone') {
- $this->utils->addFlash('success', 'success.reminder.done');
- }
-
- if ($this->request->isXmlHttpRequest()) {
- $response['flashMessages'] = $this->utils->getFlashMessages();
- return new Response(json_encode($response));
- } else {
- return parent::redirectToReferrer();
- }
- }
-
- public function setReminderDoneAction()
- {
- $id = $this->request->query->get('id');
- $done = $this->request->query->get('done');
-
- $easyadmin = $this->request->attributes->get('easyadmin');
- $reminder = $easyadmin['item'];
-
- $reminder->setDone($done);
- $this->em->persist($reminder);
- $this->em->flush();
- return $this->redirectToReferrer();
- }
- }
|