setHelp(
<<<'EOT'
The %command.name% command deletes non-primary companies of every contact.
php %command.full_name%
EOT
);
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$allowMultiple = $this->coreParametersHelper->get('contact_allow_multiple_companies');
// We process only if the config is set to false
if ($allowMultiple) {
$output->writeln($this->translator->trans('mautic.lead.command.delete_contact_secondary_company.allow_multiple_enabled'));
return Command::SUCCESS;
}
try {
$this->companyLeadsRepository->removeAllSecondaryCompanies();
} catch (ORMException $e) {
$errorMessage = $this->translator->trans('mautic.lead.command.error', ['%name%' => self::NAME, '%error%' => $e->getMessage()]);
$output->writeln($errorMessage);
$this->logger->error($errorMessage);
}
$output->writeln($this->translator->trans('mautic.lead.command.delete_contact_secondary_company.success'));
return Command::SUCCESS;
}
}