framework = $framework; parent::__construct(); } protected function configure(): void { $this ->setName(self::$defaultName) ->addOption('start', 'b', InputOption::VALUE_REQUIRED, 'Custom start date') ->addOption('stop', 'x', InputOption::VALUE_REQUIRED, 'Custom stop date') ->setDescription('Export orders from Shopware instance') ; } protected function interact(InputInterface $input, OutputInterface $output): void { if ((null !== $input->getOption('start') && null === $input->getOption('stop')) || (null === $input->getOption('start') && null !== $input->getOption('stop'))) { throw new \RuntimeException('You need to provide start and stop date.'); } if (null !== $input->getOption('start')) { try { new \DateTime($input->getOption('start')); $this->start = $input->getOption('start'); } catch(\Exception $e) { throw new \InvalidArgumentException('Start date is invalid. Please provide an ISO date.'); } } if (null !== $input->getOption('stop')) { try { new \DateTime($input->getOption('stop')); $this->stop = $input->getOption('stop'); } catch(\Exception $e) { throw new \InvalidArgumentException('Stop date is invalid. Please provide an ISO date.'); } } } protected function execute(InputInterface $input, OutputInterface $output): int { $this->framework->initialize(); $io = new SymfonyStyle($input, $output); $io->title('Orders export from Shopware'); /** @var ShopwareExportOrdersJob $export */ $export = System::getContainer()->get(ShopwareExportOrdersJob::class); $export->export('cli', $this->start,$this->stop, $io); return 0; } }