vendor/symfony/monolog-bridge/Processor/WebProcessor.php line 34

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bridge\Monolog\Processor;
  11. use Monolog\Processor\WebProcessor as BaseWebProcessor;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. use Symfony\Component\HttpKernel\Event\RequestEvent;
  14. use Symfony\Component\HttpKernel\KernelEvents;
  15. /**
  16.  * WebProcessor override to read from the HttpFoundation's Request.
  17.  *
  18.  * @author Jordi Boggiano <j.boggiano@seld.be>
  19.  *
  20.  * @final
  21.  */
  22. class WebProcessor extends BaseWebProcessor implements EventSubscriberInterface
  23. {
  24.     public function __construct(array $extraFields null)
  25.     {
  26.         // Pass an empty array as the default null value would access $_SERVER
  27.         parent::__construct([], $extraFields);
  28.     }
  29.     public function onKernelRequest(RequestEvent $event)
  30.     {
  31.         if ($event->isMainRequest()) {
  32.             $this->serverData $event->getRequest()->server->all();
  33.             $this->serverData['REMOTE_ADDR'] = $event->getRequest()->getClientIp();
  34.         }
  35.     }
  36.     public static function getSubscribedEvents(): array
  37.     {
  38.         return [
  39.             KernelEvents::REQUEST => ['onKernelRequest'4096],
  40.         ];
  41.     }
  42. }