src/Controller/DashboardController.php line 109

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\SettingsService;
  4. use App\Service\UtilService;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Cookie;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  11. use Symfony\Component\Mailer\MailerInterface;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use App\Functions\CMIMail;
  15. use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
  16. use Twig\Environment;
  17. class DashboardController extends AbstractController
  18. {
  19.     public $objSettingsService;
  20.     public $requestStack;
  21.     public $session;
  22.     public $mailer;
  23.     public $params;
  24.     public $em;
  25.     private $twig;
  26.     public function __construct(ContainerBagInterface $paramsSessionInterface $sessionRequestStack $requestStackEntityManagerInterface $emMailerInterface $mailerSettingsService $objSettingsServiceEnvironment $twig)
  27.     {
  28.         $this->objSettingsService $objSettingsService;
  29.         $this->requestStack $requestStack;
  30.         $this->session $session;
  31.         $this->mailer $mailer;
  32.         $this->params $params;
  33.         $this->em $em;
  34.         $this->twig $twig;
  35.     }
  36.     /**
  37.      * @Route("/dashboard", name="dashboard")
  38.      */
  39.     public function dashboard()
  40.     {
  41.         $intouchbizAdminUser $_SESSION['intouchbiz_admin_user'] ?? '';
  42.         $this->session->set('intouchbiz_admin_user'$intouchbizAdminUser);
  43.         return $this->render('dashboard/index.html.twig', [
  44.             'em' => $this->em,
  45.             'controllerName' => 'DashboardController',
  46.         ]);
  47.     }
  48.     /**
  49.      * @Route("/dashboard/sendmail", name="dashboard_sendmail")
  50.      */
  51.     public function sendmail(Request $request)
  52.     {
  53.         $objMail = new CMIMail($request$this->params$this->objSettingsService);
  54.         $options['att'] = ['filename' => 'data/product/img1.jpg''name' => 'IMG1'];
  55.         $options['embeddedImage'] = ['filename' => 'data/product/drum.jpg''ref' => 'drum'];
  56.         dd($objMail->send('eduardomaruk@live.com''Título de envio de imagem de ação''Ta aí as iamgens <img src="cid:drum"> e depois nada'$options));
  57.         return $this->render('dashboard/index.html.twig', [
  58.             'controllerName' => 'DashboardController',
  59.         ]);
  60.     }
  61.     /**
  62.      * @Route("/cookieConsent", name="backoffice_cookie_consent", methods={"POST"})
  63.      */
  64.     public function cookieConsent(Request $request)
  65.     {
  66.         $email $request->request->get('email');
  67.         $appVersionBackOffice $this->objSettingsService->getEnvVars('APP_VERSION_BACKOFFICE');
  68.         $appVersionCookiePolicy $this->objSettingsService->getSettingsVars('APP_VERSION_COOKIE_POLICY');
  69.         $backofficeUrl $this->objSettingsService->getEnvVars('BACKOFFICE_URL');
  70.         $objUtilService = new UtilService($this->params$this->requestStack);
  71.         $date $objUtilService->getDate('now');
  72.         $content 'Privacy Policy ID: ' $appVersionBackOffice ' | Agreed in ' $date;
  73.         $objCookieConsentController = new CookieConsentController();
  74.         $objCookieConsentController->setConsent($this->em$backofficeUrl$email$appVersionBackOffice$appVersionCookiePolicy);
  75.         $cookie = new Cookie('cookie-consent-' $appVersionCookiePolicy$contentstrtotime('now + 1 year'));
  76.         $response = new Response();
  77.         $response->headers->setCookie($cookie);
  78.         $response->setContent(json_encode([
  79.             'gtmHead' => $this->twig->render('base_gtm_head.html.twig')
  80.         ]));
  81.         $response->headers->set('Content-Type''application/json');
  82.         $response->send();
  83.         exit();
  84.     }
  85.     /**
  86.      * @Route("/privacy-policy", name="backoffice_privacy_policy")
  87.      */
  88.     public function privacyPolicy()
  89.     {
  90.         dd('privacy');
  91.     }
  92.     /**
  93.      * @Route("/logout", name="app_logout")
  94.      */
  95.     public function logout()
  96.     {
  97.         throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
  98.     }
  99. }