setName('mail:account:debug'); $this->setDescription('Enable or Disable IMAP/SMTP debugging for an account'); $this->addArgument(self::ARGUMENT_ACCOUNT_ID, InputArgument::REQUIRED); $this->addOption(self::OPTION_DEBUG_ON, null, InputOption::VALUE_NONE); $this->addOption(self::OPTION_DEBUG_OFF, null, InputOption::VALUE_NONE); } protected function execute(InputInterface $input, OutputInterface $output): int { $accountId = (int)$input->getArgument(self::ARGUMENT_ACCOUNT_ID); $debugOn = $input->getOption(self::OPTION_DEBUG_ON); $debugOff = $input->getOption(self::OPTION_DEBUG_OFF); $debug = false; try { $account = $this->accountService->findById($accountId)->getMailAccount(); } catch (DoesNotExistException $e) { $output->writeln("Account $accountId does not exist"); return 1; } if ($debugOn && $debugOff) { $output->writeln('Cannot use both --on and --off at the same time'); return 1; } if ($debugOn) { $debug = true; } $account->setDebug($debug); $this->accountService->save($account); return 0; } }