for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Rafał Muszyński <[email protected]>
* @copyright 2015 Sourcefabric z.ú.
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*/
namespace Newscoop\PaywallBundle\Importer;
use Sylius\Component\Currency\Model\CurrencyInterface;
use Sylius\Component\Currency\Importer\AbstractImporter as BaseImporter;
abstract class AbstractImporter extends BaseImporter
{
protected $baseCurrency;
* {@inheritdoc}
protected function updateOrCreate(array $managedCurrencies, $code, $rate)
if (!empty($managedCurrencies)) {
foreach ($managedCurrencies as $currency) {
if ($currency->getCode() !== $this->baseCurrency) {
$currency->setDefault(false);
} else {
$currency->setDefault(true);
}
if ($code === $currency->getCode()) {
$currency->setExchangeRate($rate);
$currency->setUpdatedAt(new \DateTime());
return;
/** @var $currency CurrencyInterface */
$currency = $this->repository->createNew();
$currency->setCode($code);
if ($currency->getCode() === $this->baseCurrency) {
$currency->setIsActive(true);
$this->manager->persist($currency);