db backup prior to drupal security update
[yaffs-website] / vendor / drupal / console / src / Command / Config / ValidateCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Config\ValidateCommand.
6  */
7
8 namespace Drupal\Console\Command\Config;
9
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Symfony\Component\Console\Command\Command;
13 use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
14 use Drupal\Console\Core\Style\DrupalStyle;
15 use Drupal\Core\Config\TypedConfigManagerInterface;
16 use Symfony\Component\Console\Input\InputArgument;
17 use Drupal\Core\Config\Schema\SchemaCheckTrait;
18
19 /**
20  * Class ValidateCommand.
21  *
22  * @package Drupal\Console\Command\Config
23  */
24 class ValidateCommand extends Command
25 {
26     use ContainerAwareCommandTrait;
27     use SchemaCheckTrait;
28     use PrintConfigValidationTrait;
29
30     /**
31    * {@inheritdoc}
32    */
33     protected function configure()
34     {
35         $this
36             ->setName('config:validate')
37             ->setDescription($this->trans('commands.config.validate.description'))
38             ->addArgument('config.name', InputArgument::REQUIRED);
39     }
40
41     /**
42    * {@inheritdoc}
43    */
44     protected function execute(InputInterface $input, OutputInterface $output)
45     {
46
47         /**
48          * @var TypedConfigManagerInterface $typedConfigManager
49          */
50         $typedConfigManager = $this->get('config.typed');
51
52         $io = new DrupalStyle($input, $output);
53
54         //Test the config name and see if a schema exists, if not it will fail
55         $name = $input->getArgument('config.name');
56         if (!$typedConfigManager->hasConfigSchema($name)) {
57             $io->warning($this->trans('commands.config.validate.messages.no-conf'));
58             return 1;
59         }
60
61         //Get the config data from the factory
62         $configFactory = $this->get('config.factory');
63         $config_data = $configFactory->get($name)->get();
64
65         return $this->printResults($this->checkConfigSchema($typedConfigManager, $name, $config_data), $io);
66     }
67 }