Version 1
[yaffs-website] / vendor / drupal / console / src / Bootstrap / FindCommandsCompilerPass.php
diff --git a/vendor/drupal/console/src/Bootstrap/FindCommandsCompilerPass.php b/vendor/drupal/console/src/Bootstrap/FindCommandsCompilerPass.php
new file mode 100644 (file)
index 0000000..42648b4
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace Drupal\Console\Bootstrap;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+
+/**
+ * FindCommandsCompilerPass
+ */
+class FindCommandsCompilerPass implements CompilerPassInterface
+{
+    /**
+     * @var string
+     */
+    protected $serviceTag;
+
+    /**
+     * FindCommandsCompilerPass constructor.
+     *
+     * @param $serviceTag
+     */
+    public function __construct($serviceTag)
+    {
+        $this->serviceTag = $serviceTag;
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function process(ContainerBuilder $container)
+    {
+        $taggedServices = $container->findTaggedServiceIds(
+            $this->serviceTag
+        );
+
+        $commands = [];
+        foreach ($taggedServices as $id => $tags) {
+            $commands[] = $id;
+        }
+
+        $container->setParameter('drupal.commands', $commands);
+    }
+}