[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/DataCollector/ -> EventDataCollector.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\HttpKernel\DataCollector;
  13  
  14  use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
  15  use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  16  use Symfony\Component\HttpFoundation\Request;
  17  use Symfony\Component\HttpFoundation\Response;
  18  
  19  /**
  20   * EventDataCollector.
  21   *
  22   * @author Fabien Potencier <fabien@symfony.com>
  23   */
  24  class EventDataCollector extends DataCollector implements LateDataCollectorInterface
  25  {
  26      protected $dispatcher;
  27  
  28      public function __construct(EventDispatcherInterface $dispatcher = null)
  29      {
  30          $this->dispatcher = $dispatcher;
  31      }
  32  
  33      /**
  34       * {@inheritdoc}
  35       */
  36      public function collect(Request $request, Response $response, \Exception $exception = null)
  37      {
  38          $this->data = array(
  39              'called_listeners' => array(),
  40              'not_called_listeners' => array(),
  41          );
  42      }
  43  
  44      public function lateCollect()
  45      {
  46          if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
  47              $this->setCalledListeners($this->dispatcher->getCalledListeners());
  48              $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners());
  49          }
  50      }
  51  
  52      /**
  53       * Sets the called listeners.
  54       *
  55       * @param array $listeners An array of called listeners
  56       *
  57       * @see TraceableEventDispatcherInterface
  58       */
  59      public function setCalledListeners(array $listeners)
  60      {
  61          $this->data['called_listeners'] = $listeners;
  62      }
  63  
  64      /**
  65       * Gets the called listeners.
  66       *
  67       * @return array An array of called listeners
  68       *
  69       * @see TraceableEventDispatcherInterface
  70       */
  71      public function getCalledListeners()
  72      {
  73          return $this->data['called_listeners'];
  74      }
  75  
  76      /**
  77       * Sets the not called listeners.
  78       *
  79       * @param array $listeners An array of not called listeners
  80       *
  81       * @see TraceableEventDispatcherInterface
  82       */
  83      public function setNotCalledListeners(array $listeners)
  84      {
  85          $this->data['not_called_listeners'] = $listeners;
  86      }
  87  
  88      /**
  89       * Gets the not called listeners.
  90       *
  91       * @return array An array of not called listeners
  92       *
  93       * @see TraceableEventDispatcherInterface
  94       */
  95      public function getNotCalledListeners()
  96      {
  97          return $this->data['not_called_listeners'];
  98      }
  99  
 100      /**
 101       * {@inheritdoc}
 102       */
 103      public function getName()
 104      {
 105          return 'events';
 106      }
 107  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1