5 * Contains \Drupal\Console\Core\Command\CheckCommand.
8 namespace Drupal\Console\Core\Command;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Symfony\Component\Console\Command\Command as BaseCommand;
13 use Drupal\Console\Core\Command\Shared\CommandTrait;
14 use Drupal\Console\Core\Utils\ConfigurationManager;
15 use Drupal\Console\Core\Utils\RequirementChecker;
16 use Drupal\Console\Core\Utils\ChainQueue;
17 use Drupal\Console\Core\Style\DrupalStyle;
21 * @package Drupal\Console\Core\Command
23 class CheckCommand extends BaseCommand
28 * @var RequirementChecker
30 protected $requirementChecker;
35 protected $chainQueue;
38 * @var ConfigurationManager
40 protected $configurationManager;
43 * CheckCommand constructor.
44 * @param RequirementChecker $requirementChecker
45 * @param ChainQueue $chainQueue
46 * @param ConfigurationManager $configurationManager
48 public function __construct(
49 RequirementChecker $requirementChecker,
50 ChainQueue $chainQueue,
51 ConfigurationManager $configurationManager
53 $this->requirementChecker = $requirementChecker;
54 $this->chainQueue = $chainQueue;
55 $this->configurationManager = $configurationManager;
57 parent::__construct();
63 protected function configure()
67 ->setDescription($this->trans('commands.check.description'));
73 protected function execute(InputInterface $input, OutputInterface $output)
75 $io = new DrupalStyle($input, $output);
77 $checks = $this->requirementChecker->getCheckResult();
79 $phpCheckFile = $this->configurationManager->getHomeDirectory().'/.console/phpcheck.yml';
80 $phpCheckFileDisplay = realpath($this->configurationManager->getHomeDirectory()).'/.console/phpcheck.yml';
82 if (!file_exists($phpCheckFile)) {
84 $this->configurationManager->getApplicationDirectory().
86 'config/dist/phpcheck.yml';
88 $phpCheckFileDisplay =
89 realpath($this->configurationManager->getApplicationDirectory()).
91 'config/dist/phpcheck.yml';
95 $io->info($this->trans('commands.check.messages.file'));
96 $io->comment($phpCheckFileDisplay);
98 $checks = $this->requirementChecker->validate($phpCheckFile);
101 if (!$checks['php']['valid']) {
104 $this->trans('commands.check.messages.php_invalid'),
105 $checks['php']['current'],
106 $checks['php']['required']
113 if ($extensions = $checks['extensions']['required']['missing']) {
114 foreach ($extensions as $extension) {
117 $this->trans('commands.check.messages.extension_missing'),
124 if ($extensions = $checks['extensions']['recommended']['missing']) {
125 foreach ($extensions as $extension) {
129 'commands.check.messages.extension_recommended'
137 if ($configurations = $checks['configurations']['required']['missing']) {
138 foreach ($configurations as $configuration) {
141 $this->trans('commands.check.messages.configuration_missing'),
148 if ($configurations = $checks['configurations']['required']['overwritten']) {
149 foreach ($configurations as $configuration => $overwritten) {
153 'commands.check.messages.configuration_overwritten'
162 if ($this->requirementChecker->isValid() && !$this->requirementChecker->isOverwritten()) {
164 $this->trans('commands.check.messages.success')
168 return $this->requirementChecker->isValid();