Files
chill-bundles/src/Bundle/ChillMainBundle/Command/LoadAddressesFRFromBANCommand.php
2025-11-03 16:22:33 +01:00

40 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Command;
use Chill\MainBundle\Service\Import\AddressReferenceFromBAN;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:main:address-ref-from-ban')]
class LoadAddressesFRFromBANCommand
{
protected static $defaultDescription = 'Import FR addresses from BAN (see https://adresses.data.gouv.fr';
public function __construct(private readonly AddressReferenceFromBAN $addressReferenceFromBAN) {}
public function __invoke(#[\Symfony\Component\Console\Attribute\Argument(name: 'departementNo', description: 'a list of departement numbers')]
array $departementno, #[\Symfony\Component\Console\Attribute\Option(name: 'send-report-email', shortcut: 's', mode: InputOption::VALUE_REQUIRED, description: 'Email address where a list of unimported addresses can be send')]
$sendReportEmail, OutputInterface $output): int
{
dump(__METHOD__);
foreach ($departementNo as $departementNo) {
$output->writeln('Import addresses for '.$departementNo);
$this->addressReferenceFromBAN->import($departementNo, $input->hasOption('send-report-email') ? $send_report_email : null);
}
return Command::SUCCESS;
}
}