5 * Contains \Drupal\Console\Command\Debug\DebugCommand.
8 namespace Drupal\Console\Command\Debug;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Core\Command\Command;
14 use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
15 use Drupal\Core\State\StateInterface;
16 use Drupal\Component\Serialization\Yaml;
21 * @package Drupal\Console\Command\Debug
23 class StateCommand extends Command
31 * @var KeyValueFactoryInterface
36 * DebugCommand constructor.
38 * @param StateInterface $state
39 * @param KeyValueFactoryInterface $keyValue
41 public function __construct(
42 StateInterface $state,
43 KeyValueFactoryInterface $keyValue
45 $this->state = $state;
46 $this->keyValue = $keyValue;
47 parent::__construct();
53 protected function configure()
56 ->setName('debug:state')
57 ->setDescription($this->trans('commands.debug.state.description'))
60 InputArgument::OPTIONAL,
61 $this->trans('commands.debug.state.arguments.key')
63 ->setHelp($this->trans('commands.debug.state.help'))
64 ->setAliases(['dst']);
70 protected function execute(InputInterface $input, OutputInterface $output)
72 $key = $input->getArgument('key');
75 $this->getIo()->info($key);
76 $this->getIo()->writeln(Yaml::encode($this->state->get($key)));
81 $tableHeader = [$this->trans('commands.debug.state.messages.key')];
82 $keyStoreStates = array_keys($this->keyValue->get('state')->getAll());
83 $this->getIo()->table($tableHeader, $keyStoreStates);