setName(self::COMMAND_NAME) ->setDescription('Delete all stored ip addresses.'); } protected function execute(InputInterface $input, OutputInterface $output): int { if (!$this->coreParametersHelper->get('anonymize_ip')) { return $this->exitWithError('Anonymization could not be done because anonymize Ip feature is disabled for this instance.', $output); } try { $anonymizedRows = $this->ipAddressRepository->anonymizeAllIpAddress(); $anonymizedRows += $this->auditLogRepository->anonymizeAllIpAddress(); $output->writeln(sprintf('%s IP addresses have been anonymized', $anonymizedRows)); } catch (DBALException $e) { return $this->exitWithError(sprintf('Anonymization of IP addresses failed because of database error: %s', $e->getMessage()), $output); } return 0; } private function exitWithError(string $message, OutputInterface $output): int { $output->writeln(sprintf('%s', $message)); return 1; } }