5 * Contains \Drupal\Console\Command\Config\ValidateCommand.
8 namespace Drupal\Console\Command\Config;
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;
20 * Class ValidateCommand.
22 * @package Drupal\Console\Command\Config
24 class ValidateCommand extends Command
26 use ContainerAwareCommandTrait;
28 use PrintConfigValidationTrait;
33 protected function configure()
36 ->setName('config:validate')
37 ->setDescription($this->trans('commands.config.validate.description'))
38 ->addArgument('config.name', InputArgument::REQUIRED);
44 protected function execute(InputInterface $input, OutputInterface $output)
48 * @var TypedConfigManagerInterface $typedConfigManager
50 $typedConfigManager = $this->get('config.typed');
52 $io = new DrupalStyle($input, $output);
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'));
61 //Get the config data from the factory
62 $configFactory = $this->get('config.factory');
63 $config_data = $configFactory->get($name)->get();
65 return $this->printResults($this->checkConfigSchema($typedConfigManager, $name, $config_data), $io);