Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / vendor / symfony / http-kernel / DataCollector / EventDataCollector.php
index 0a87bc38926deac6e809b2ddbd8b7f810a5264c2..81076fd7267761cba086b54f6133ae8cb4707a2f 100644 (file)
 
 namespace Symfony\Component\HttpKernel\DataCollector;
 
+use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
 
 /**
  * EventDataCollector.
@@ -27,6 +27,9 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
 
     public function __construct(EventDispatcherInterface $dispatcher = null)
     {
+        if ($dispatcher instanceof TraceableEventDispatcherInterface && !method_exists($dispatcher, 'reset')) {
+            @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', TraceableEventDispatcherInterface::class, \get_class($dispatcher)), E_USER_DEPRECATED);
+        }
         $this->dispatcher = $dispatcher;
     }
 
@@ -41,12 +44,26 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
         );
     }
 
+    public function reset()
+    {
+        $this->data = array();
+
+        if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
+            if (!method_exists($this->dispatcher, 'reset')) {
+                return; // @deprecated
+            }
+
+            $this->dispatcher->reset();
+        }
+    }
+
     public function lateCollect()
     {
         if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
             $this->setCalledListeners($this->dispatcher->getCalledListeners());
             $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners());
         }
+        $this->data = $this->cloneVar($this->data);
     }
 
     /**