Version 1
[yaffs-website] / vendor / drupal / console / src / Command / Module / PathCommand.php
diff --git a/vendor/drupal/console/src/Command/Module/PathCommand.php b/vendor/drupal/console/src/Command/Module/PathCommand.php
new file mode 100644 (file)
index 0000000..a716cde
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Console\Command\Module\PathCommand.
+ */
+
+namespace Drupal\Console\Command\Module;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Shared\CommandTrait;
+use Drupal\Console\Command\Shared\ModuleTrait;
+use Drupal\Console\Core\Style\DrupalStyle;
+use Drupal\Console\Extension\Manager;
+
+class PathCommand extends Command
+{
+    use CommandTrait;
+    use ModuleTrait;
+
+    /**
+     * @var Manager
+     */
+    protected $extensionManager;
+
+    /**
+     * PathCommand constructor.
+     *
+     * @param Manager $extensionManager
+     */
+    public function __construct(Manager $extensionManager)
+    {
+        $this->extensionManager = $extensionManager;
+        parent::__construct();
+    }
+
+    protected function configure()
+    {
+        $this
+            ->setName('module:path')
+            ->setDescription($this->trans('commands.module.path.description'))
+            ->addArgument(
+                'module',
+                InputArgument::REQUIRED,
+                $this->trans('commands.module.path.arguments.module')
+            )
+            ->addOption(
+                'absolute',
+                '',
+                InputOption::VALUE_NONE,
+                $this->trans('commands.module.path.options.absolute')
+            );
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $io = new DrupalStyle($input, $output);
+
+        $module = $input->getArgument('module');
+
+        $fullPath = $input->getOption('absolute');
+
+        $module = $this->extensionManager->getModule($module);
+
+        $io->info(
+            $module->getPath($fullPath)
+        );
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function interact(InputInterface $input, OutputInterface $output)
+    {
+        $io = new DrupalStyle($input, $output);
+
+        // --module argument
+        $module = $input->getArgument('module');
+        if (!$module) {
+            // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
+            $module = $this->moduleQuestion($io);
+            $input->setArgument('module', $module);
+        }
+    }
+}