vendor/sulu/sulu/src/Sulu/Bundle/WebsiteBundle/EventSubscriber/GeneratorEventSubscriber.php line 40

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Sulu.
  4. *
  5. * (c) Sulu GmbH
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Sulu\Bundle\WebsiteBundle\EventSubscriber;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  13. use Symfony\Component\HttpKernel\KernelEvents;
  14. /**
  15. * Adds the X-Generator header.
  16. */
  17. class GeneratorEventSubscriber implements EventSubscriberInterface
  18. {
  19. /**
  20. * @var string
  21. */
  22. private $version;
  23. public function __construct($version)
  24. {
  25. $this->version = $version;
  26. }
  27. public static function getSubscribedEvents()
  28. {
  29. return [
  30. KernelEvents::RESPONSE => 'onResponse',
  31. ];
  32. }
  33. public function onResponse(ResponseEvent $event)
  34. {
  35. $event->getResponse()->headers->set('X-Generator', 'Sulu/' . $this->version);
  36. }
  37. }