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;
22 * @package Drupal\Console\Core\Command
24 class CheckCommand extends BaseCommand
29 * @var RequirementChecker
31 protected $requirementChecker;
36 protected $chainQueue;
39 * @var ConfigurationManager
41 protected $configurationManager;
44 * CheckCommand constructor.
46 * @param RequirementChecker $requirementChecker
47 * @param ChainQueue $chainQueue
48 * @param ConfigurationManager $configurationManager
50 public function __construct(
51 RequirementChecker $requirementChecker,
52 ChainQueue $chainQueue,
53 ConfigurationManager $configurationManager
55 $this->requirementChecker = $requirementChecker;
56 $this->chainQueue = $chainQueue;
57 $this->configurationManager = $configurationManager;
59 parent::__construct();
65 protected function configure()
69 ->setDescription($this->trans('commands.check.description'));
75 protected function execute(InputInterface $input, OutputInterface $output)
77 $io = new DrupalStyle($input, $output);
79 $checks = $this->requirementChecker->getCheckResult();
81 $phpCheckFile = $this->configurationManager->getHomeDirectory().'/.console/phpcheck.yml';
83 if (!file_exists($phpCheckFile)) {
85 $this->configurationManager->getApplicationDirectory().
87 'config/dist/phpcheck.yml';
91 $io->info($this->trans('commands.check.messages.file'));
92 $io->comment($phpCheckFile);
94 $checks = $this->requirementChecker->validate($phpCheckFile);
97 if (!$checks['php']['valid']) {
100 $this->trans('commands.check.messages.php_invalid'),
101 $checks['php']['current'],
102 $checks['php']['required']
109 if ($extensions = $checks['extensions']['required']['missing']) {
110 foreach ($extensions as $extension) {
113 $this->trans('commands.check.messages.extension_missing'),
120 if ($extensions = $checks['extensions']['recommended']['missing']) {
121 foreach ($extensions as $extension) {
125 'commands.check.messages.extension_recommended'
133 if ($configurations = $checks['configurations']['required']['missing']) {
134 foreach ($configurations as $configuration) {
137 $this->trans('commands.check.messages.configuration_missing'),
144 if ($configurations = $checks['configurations']['required']['overwritten']) {
145 foreach ($configurations as $configuration => $overwritten) {
149 'commands.check.messages.configuration_overwritten'
158 if ($this->requirementChecker->isValid() && !$this->requirementChecker->isOverwritten()) {
160 $this->trans('commands.check.messages.success')
164 return $this->requirementChecker->isValid();