Version 1
[yaffs-website] / vendor / drupal / console / src / Command / Develop / GenerateDocDataCommand.php
diff --git a/vendor/drupal/console/src/Command/Develop/GenerateDocDataCommand.php b/vendor/drupal/console/src/Command/Develop/GenerateDocDataCommand.php
new file mode 100644 (file)
index 0000000..5872805
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Console\Command\Develop\GenerateDocDataCommand.
+ */
+
+namespace Drupal\Console\Command\Develop;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Style\DrupalStyle;
+use Drupal\Console\Core\Command\Shared\CommandTrait;
+
+class GenerateDocDataCommand extends Command
+{
+    use CommandTrait;
+
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function configure()
+    {
+        $this
+            ->setName('generate:doc:data')
+            ->setDescription(
+                $this->trans('commands.generate.doc.data.description')
+            )
+            ->addOption(
+                'file',
+                null,
+                InputOption::VALUE_OPTIONAL,
+                $this->trans('commands.generate.doc.data.options.file')
+            );
+        ;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+        $io = new DrupalStyle($input, $output);
+        $file = null;
+        if ($input->hasOption('file')) {
+            $file = $input->getOption('file');
+        }
+
+        $data = $this->getApplication()->getData();
+        if ($file) {
+            file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT));
+
+            return 0;
+        }
+
+        $io->write(json_encode($data, JSON_PRETTY_PRINT));
+    }
+}