Security update for Core, with self-updated composer
[yaffs-website] / vendor / consolidation / annotated-command / src / Hooks / HookManager.php
index 89cd319379744c9c59ce35443dd902df18e31a14..ade39aaed93702899a3220e3fd7690bed301b9c7 100644 (file)
@@ -8,6 +8,8 @@ use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\ConsoleEvents;
 use Symfony\Component\Console\Event\ConsoleCommandEvent;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\EventDispatcher;
 
 use Consolidation\AnnotatedCommand\ExitCodeInterface;
 use Consolidation\AnnotatedCommand\OutputDataInterface;
@@ -132,6 +134,32 @@ class HookManager implements EventSubscriberInterface
         return $this;
     }
 
+    public function addPreCommandEventDispatcher(EventDispatcherInterface $eventDispatcher, $name = '*')
+    {
+        $this->hooks[$name][self::PRE_COMMAND_EVENT][] = $eventDispatcher;
+        return $this;
+    }
+
+    public function addCommandEventDispatcher(EventDispatcherInterface $eventDispatcher, $name = '*')
+    {
+        $this->hooks[$name][self::COMMAND_EVENT][] = $eventDispatcher;
+        return $this;
+    }
+
+    public function addPostCommandEventDispatcher(EventDispatcherInterface $eventDispatcher, $name = '*')
+    {
+        $this->hooks[$name][self::POST_COMMAND_EVENT][] = $eventDispatcher;
+        return $this;
+    }
+
+    public function addCommandEvent(EventSubscriberInterface $eventSubscriber)
+    {
+        // Wrap the event subscriber in a dispatcher and add it
+        $dispatcher = new EventDispatcher();
+        $dispatcher->addSubscriber($eventSubscriber);
+        return $this->addCommandEventDispatcher($dispatcher);
+    }
+
     /**
      * Add an configuration provider hook
      *