|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Drupal\Console\Dotenv\Command; |
| 4 | + |
| 5 | +use Symfony\Component\Console\Input\InputInterface; |
| 6 | +use Symfony\Component\Console\Output\OutputInterface; |
| 7 | +use Symfony\Component\Console\Command\Command; |
| 8 | +use Drupal\Console\Core\Command\Shared\CommandTrait; |
| 9 | +use Drupal\Console\Core\Style\DrupalStyle; |
| 10 | +use Symfony\Component\Filesystem\Filesystem; |
| 11 | +use Drupal\Component\Utility\Crypt; |
| 12 | +use Webmozart\PathUtil\Path; |
| 13 | + |
| 14 | +/** |
| 15 | + * Class ExampleOneCommand |
| 16 | + * |
| 17 | + * @package Drupal\Console\Dotenv\Command |
| 18 | + */ |
| 19 | +class DebugCommand extends Command |
| 20 | +{ |
| 21 | + use CommandTrait; |
| 22 | + |
| 23 | + /** |
| 24 | + * @var string |
| 25 | + */ |
| 26 | + protected $appRoot; |
| 27 | + |
| 28 | + /** |
| 29 | + * @var string |
| 30 | + */ |
| 31 | + protected $consoleRoot; |
| 32 | + |
| 33 | + /** |
| 34 | + * InitCommand constructor. |
| 35 | + * |
| 36 | + * @param string $appRoot |
| 37 | + * @param string $consoleRoot |
| 38 | + */ |
| 39 | + public function __construct( |
| 40 | + $appRoot, |
| 41 | + $consoleRoot = null |
| 42 | + ) |
| 43 | + { |
| 44 | + $this->appRoot = $appRoot; |
| 45 | + $this->consoleRoot = $consoleRoot?$consoleRoot:$appRoot; |
| 46 | + parent::__construct(); |
| 47 | + } |
| 48 | + |
| 49 | + protected function configure() |
| 50 | + { |
| 51 | + $this->setName('dotenv:debug') |
| 52 | + ->setDescription('Debug Dotenv debug values.'); |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * {@inheritdoc} |
| 57 | + */ |
| 58 | + protected function execute(InputInterface $input, OutputInterface $output) |
| 59 | + { |
| 60 | + $io = new DrupalStyle($input, $output); |
| 61 | + $this->copyFiles($io); |
| 62 | + } |
| 63 | + |
| 64 | + private function debugFile(DrupalStyle $io) { |
| 65 | + $fs = new Filesystem(); |
| 66 | + $envFile = $this->consoleRoot . '/.env'; |
| 67 | + if (!$fs->exists($envFile)) { |
| 68 | + $io->warning('File '. $envFile . ' not found.'); |
| 69 | + |
| 70 | + return 1; |
| 71 | + } |
| 72 | + |
| 73 | + $fileContent = file_get_contents($envFile); |
| 74 | + $io->writeln($fileContent); |
| 75 | + } |
| 76 | +} |
0 commit comments