Files
CdsConnector/src/Command/HiltesImportCommand.php
mmoeller 3493e038e3
Some checks failed
continuous-integration/drone/push Build is failing
import hiltes
2023-01-30 15:36:20 +01:00

61 lines
1.7 KiB
PHP

<?php
namespace App\Command;
use App\Helper\HiltesImport;
use App\Repository\StockRepository;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Finder\Finder;
#[AsCommand(
name: 'hiltes:import',
description: 'Importiert die Bestandsdaten von Hiltes',
)]
class HiltesImportCommand extends Command
{
private $stockRepository;
private $logger;
public function __construct(StockRepository $stockRepository, LoggerInterface $logger)
{
$this->stockRepository = $stockRepository;
$this->logger = $logger;
parent::__construct();
}
protected function configure(): void
{
$this
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description')
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$arg1 = $input->getArgument('arg1');
if ($arg1) {
$io->note(sprintf('You passed an argument: %s', $arg1));
}
/**
* @var HiltesImport
*/
$hiltesImport = new HiltesImport($this->stockRepository,$this->logger);
$hiltesImport->startImport();
$io->success('Done.');
return Command::SUCCESS;
}
}