<?php
namespace App\Command;
use App\Util\DocExplUtil;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ParseProductBalanceBlankCommand extends ContainerAwareCommand
{
protected static $defaultName = 'app:parse-product-balance-blank';
/**
* @var DocExplUtil
*/
protected $docExplUtil;
/**
* @param DocExplUtil $docExplUtil
*/
public function __construct(DocExplUtil $docExplUtil)
{
parent::__construct();
$this->docExplUtil = $docExplUtil;
}
/**
* {@inheritdoc}
*/
protected function configure(): void
{
$this->setDescription('Parse product balances from expl.xml');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): void
{
$fileName = 'expl.xml';
$fileDir = $this->getContainer()->getParameter('kernel.root_dir').'/../var/storage/';
$filePath = $fileDir.$fileName;
try {
$this->docExplUtil->processFile($filePath);
// unlink($filePath);
} catch (\Throwable $e) {
$output->writeln('Error: '.$e->getMessage());
}
}
}