util = $util; $this->config = $config; $this->questionHelper = $questionHelper; parent::__construct(); } protected function configure() { $this ->setName('encryption:enable-master-key') ->setDescription('Enable the master key. Only available for fresh installations with no existing encrypted data! There is also no way to disable it again.'); } protected function execute(InputInterface $input, OutputInterface $output): int { $isAlreadyEnabled = $this->util->isMasterKeyEnabled(); if ($isAlreadyEnabled) { $output->writeln('Master key already enabled'); } else { $question = new ConfirmationQuestion( 'Warning: Only available for fresh installations with no existing encrypted data! ' . 'There is also no way to disable it again. Do you want to continue? (y/n) ', false); if ($this->questionHelper->ask($input, $output, $question)) { $this->config->setAppValue('encryption', 'useMasterKey', '1'); $output->writeln('Master key successfully enabled.'); } else { $output->writeln('aborted.'); return 1; } } return 0; } }