| @@ 23-81 (lines=59) @@ | ||
| 20 | * extensionType="module" |
|
| 21 | * ) |
|
| 22 | */ |
|
| 23 | class SettingsCommand extends ContainerAwareCommand { |
|
| 24 | ||
| 25 | const NAME = 'commands.mongodb.settings'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * The mongodb.tools service. |
|
| 29 | * |
|
| 30 | * @var \Drupal\mongodb\Install\Tools |
|
| 31 | */ |
|
| 32 | protected $tools; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * The serialization.yaml service. |
|
| 36 | * |
|
| 37 | * @var \Drupal\Component\Serialization\SerializationInterface |
|
| 38 | */ |
|
| 39 | protected $serialization; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * SettingsCommand constructor. |
|
| 43 | * |
|
| 44 | * @param \Drupal\mongodb\Install\Tools $tools |
|
| 45 | * The mongodb.tools service. |
|
| 46 | * @param \Drupal\Component\Serialization\SerializationInterface $yaml |
|
| 47 | * The serialization.yaml service. |
|
| 48 | */ |
|
| 49 | public function __construct(Tools $tools, SerializationInterface $yaml) { |
|
| 50 | parent::__construct(); |
|
| 51 | $this->serialization = $yaml; |
|
| 52 | $this->tools = $tools; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * {@inheritdoc} |
|
| 57 | */ |
|
| 58 | protected function configure() { |
|
| 59 | $name = static::NAME; |
|
| 60 | ||
| 61 | $this |
|
| 62 | ->setName('mongodb:settings') |
|
| 63 | ->setAliases(['mdbs', 'mo-set']) |
|
| 64 | ->setDescription($this->trans("${name}.description")) |
|
| 65 | ->setHelp($this->trans("${name}.help")); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * {@inheritdoc} |
|
| 70 | */ |
|
| 71 | protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 72 | $this |
|
| 73 | ->getIo() |
|
| 74 | ->write( |
|
| 75 | $this->serialization->encode( |
|
| 76 | $this->tools->settings() |
|
| 77 | ) |
|
| 78 | ); |
|
| 79 | } |
|
| 80 | ||
| 81 | } |
|
| 82 | ||
| @@ 23-72 (lines=50) @@ | ||
| 20 | * extensionType="module" |
|
| 21 | * ) |
|
| 22 | */ |
|
| 23 | class SanityCheckCommand extends ContainerAwareCommand { |
|
| 24 | ||
| 25 | /** |
|
| 26 | * The mongodb.watchdog.sanity_check service. |
|
| 27 | * |
|
| 28 | * @var \Drupal\mongodb_watchdog\Install\Sanitycheck |
|
| 29 | */ |
|
| 30 | protected $sanityCheck; |
|
| 31 | ||
| 32 | /** |
|
| 33 | * The serialisation.yaml service. |
|
| 34 | * |
|
| 35 | * @var \Drupal\Core\Serialization\Yaml |
|
| 36 | */ |
|
| 37 | protected $yaml; |
|
| 38 | ||
| 39 | /** |
|
| 40 | * SanityCheckCommand constructor. |
|
| 41 | * |
|
| 42 | * @param \Drupal\mongodb_watchdog\Install\Sanitycheck $sanityCheck |
|
| 43 | * The mongodb.watchdog.sanity_check service. |
|
| 44 | * @param \Drupal\Component\Serialization\Yaml $yaml |
|
| 45 | * The serialization.yaml service. |
|
| 46 | */ |
|
| 47 | public function __construct(Sanitycheck $sanityCheck, Yaml $yaml) { |
|
| 48 | parent::__construct(); |
|
| 49 | $this->sanityCheck = $sanityCheck; |
|
| 50 | $this->yaml = $yaml; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * {@inheritdoc} |
|
| 55 | */ |
|
| 56 | protected function configure(): void { |
|
| 57 | $this |
|
| 58 | ->setName('mongodb:watchdog:sanitycheck') |
|
| 59 | ->setDescription($this->trans('commands.mongodb.watchdog.sanitycheck.description')) |
|
| 60 | ->setHelp($this->trans('commands.mongodb.watchdog.sanitycheck.help')) |
|
| 61 | ->setAliases(['mdbwsc', 'mowd-sc']); |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * {@inheritdoc} |
|
| 66 | */ |
|
| 67 | protected function execute(InputInterface $input, OutputInterface $output): void { |
|
| 68 | $buckets = $this->sanityCheck->buildCollectionstats(); |
|
| 69 | $this->getIo()->writeln($this->yaml->encode($buckets)); |
|
| 70 | } |
|
| 71 | ||
| 72 | } |
|
| 73 | ||