Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Debug / DotenvCommand.php
1 <?php
2
3 namespace Drupal\Console\Command\Debug;
4
5 use Symfony\Component\Console\Input\InputInterface;
6 use Symfony\Component\Console\Output\OutputInterface;
7 use Drupal\Console\Core\Command\Command;
8 use Symfony\Component\Filesystem\Filesystem;
9 use Drupal\Console\Core\Utils\DrupalFinder;
10
11 /**
12  * Class DebugCommand
13  *
14  * @package Drupal\Console\Command\Debug
15  */
16 class DotenvCommand extends Command
17 {
18     /**
19      * @var DrupalFinder
20      */
21     protected $drupalFinder;
22
23     /**
24      * InitCommand constructor.
25      *
26      * @param DrupalFinder $drupalFinder
27      */
28     public function __construct(
29         DrupalFinder $drupalFinder
30     ) {
31         $this->drupalFinder = $drupalFinder;
32         parent::__construct();
33     }
34
35     protected function configure()
36     {
37         $this->setName('debug:dotenv')
38             ->setDescription('Debug Dotenv debug values.');
39     }
40
41     /**
42      * {@inheritdoc}
43      */
44     protected function execute(InputInterface $input, OutputInterface $output)
45     {
46         $fs = new Filesystem();
47         $envFile = $this->drupalFinder->getComposerRoot() . '/.env';
48         if (!$fs->exists($envFile)) {
49             $this->getIo()->warning('File '. $envFile . ' not found.');
50
51             return 1;
52         }
53
54         $fileContent = file_get_contents($envFile);
55         $this->getIo()->writeln($fileContent);
56     }
57 }