vendor/symfony/security-bundle/Debug/WrappedListener.php line 46

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\Bundle\SecurityBundle\Debug;
  11. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  12. use Symfony\Component\Security\Http\Firewall\ListenerInterface;
  13. use Symfony\Component\VarDumper\Caster\ClassStub;
  14. /**
  15.  * Wraps a security listener for calls record.
  16.  *
  17.  * @author Robin Chalas <robin.chalas@gmail.com>
  18.  */
  19. final class WrappedListener implements ListenerInterface
  20. {
  21.     private $response;
  22.     private $listener;
  23.     private $time;
  24.     private $stub;
  25.     private static $hasVarDumper;
  26.     public function __construct(ListenerInterface $listener)
  27.     {
  28.         $this->listener $listener;
  29.         if (null === self::$hasVarDumper) {
  30.             self::$hasVarDumper class_exists(ClassStub::class);
  31.         }
  32.     }
  33.     /**
  34.      * {@inheritdoc}
  35.      */
  36.     public function handle(GetResponseEvent $event)
  37.     {
  38.         $startTime microtime(true);
  39.         $this->listener->handle($event);
  40.         $this->time microtime(true) - $startTime;
  41.         $this->response $event->getResponse();
  42.     }
  43.     /**
  44.      * Proxies all method calls to the original listener.
  45.      */
  46.     public function __call($method$arguments)
  47.     {
  48.         return \call_user_func_array([$this->listener$method], $arguments);
  49.     }
  50.     public function getWrappedListener()
  51.     {
  52.         return $this->listener;
  53.     }
  54.     public function getInfo()
  55.     {
  56.         if (null === $this->stub) {
  57.             $this->stub self::$hasVarDumper ? new ClassStub(\get_class($this->listener)) : \get_class($this->listener);
  58.         }
  59.         return [
  60.             'response' => $this->response,
  61.             'time' => $this->time,
  62.             'stub' => $this->stub,
  63.         ];
  64.     }
  65. }