src/EventSubscriber/BookMailSubscriber.php line 21

  1. <?php
  2. namespace App\EventSubscriber;
  3. use ApiPlatform\Symfony\EventListener\EventPriorities;
  4. use App\Entity\Book;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpFoundation\Request;
  7. // use Symfony\Component\HttpKernel\Event\ResponseEvent;
  8. use Symfony\Component\HttpKernel\Event\ViewEvent;
  9. use Symfony\Component\HttpKernel\KernelEvents;
  10. final class BookMailSubscriber implements EventSubscriberInterface
  11. {
  12.     public static function getSubscribedEvents()
  13.     {
  14.       // dd('here');
  15.       return [
  16.         KernelEvents::VIEW => ['sendMail'EventPriorities::POST_WRITE],
  17.       ];
  18.     }
  19.     public static function sendMail(ViewEvent $event): void
  20.     {
  21.       // dd('here');
  22.       // $response = $event->getResponse();
  23.       // $response->getContent();
  24.       // $data = $response->getContent();
  25.       // $res = gzencode($data, 1);
  26.       // $response->setContent($res);
  27.       // $response->headers->set('Content-Length', strlen($res));
  28.       // $response->headers->set('Content-Encoding', 'gzip');
  29.     }
  30. }