Files
kupshop/bundles/KupShop/KupShopBundle/Command/SharedDBUpdateCommand.php
2025-08-02 16:30:27 +02:00

46 lines
1.3 KiB
PHP

<?php
namespace KupShop\KupShopBundle\Command;
use KupShop\KupShopBundle\Event\SharedDBUpdateEvent;
use KupShop\KupShopBundle\Util\Event\LoggingEventDispatcher;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class SharedDBUpdateCommand extends Command
{
/** @var LoggingEventDispatcher */
private $eventDispatcher;
/**
* @required
*/
public function setLoggingEventDispatcher(LoggingEventDispatcher $eventDispatcher): void
{
$this->eventDispatcher = $eventDispatcher;
}
protected function configure()
{
$this->setName('kupshop:update_shared_database')
->setDescription('Import data into shared database');
$this->addOption('method', 'm', InputOption::VALUE_OPTIONAL, 'Call specific cron method - write just method, f.e.: "-m activatePoints"', false);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$event = new SharedDBUpdateEvent();
if ($input->getOption('method') !== false) {
$this->eventDispatcher->setSpecificMethod($input->getOption('method'));
}
$this->eventDispatcher->dispatch($event, SharedDBUpdateEvent::NAME);
return 0;
}
}