for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\CurrencyExchangeBundle\Command;
use GuzzleHttp\Exception\ClientException;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* A command which store currency rates in ES.
class UpdateEsRatesCommand extends ContainerAwareCommand
{
* {@inheritdoc}
protected function configure()
$this->setName('ongr:currency:update')
->setDescription('Currency Update');
}
protected function execute(InputInterface $input, OutputInterface $output)
try {
$data = $this->getContainer()->get('ongr_currency_exchange.currency_rates_service');
$data->reloadRates();
$output->writeln(sprintf('<info>Currency rates updated</info>'));
} catch (ClientException $e) {
$output->writeln(
sprintf(
'<error>Error ocurred during update. </error> <comment>`%s`</comment>',
$e->getMessage()
)
);