Skip to content

Commit

Permalink
Fixne AbstractImporter tak, aby nedocházelo pri update men k vytvaren…
Browse files Browse the repository at this point in the history
…i duplicit ale k jejich updatovani.
  • Loading branch information
divaska committed Jul 13, 2016
1 parent 5587b9e commit 7126baa
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/Sylius/Component/Currency/Importer/AbstractImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,22 @@ public function __construct(ObjectManager $manager, RepositoryInterface $reposit
*/
protected function updateOrCreate(array $managedCurrencies, $code, $rate)
{
if (!empty($managedCurrencies) && !in_array($code, $managedCurrencies)) {
foreach ($managedCurrencies as $currency) {
if ($code === $currency->getCode()) {
$currency->setExchangeRate($rate);

$this->manager->persist($currency);

return;
}
foreach ($managedCurrencies as $currency) {
if ($code === $currency->getCode()) {
$currency->setExchangeRate($rate);
$this->manager->persist($currency);
return;
}
} else {
/** @var $currency CurrencyInterface */
$currency = $this->repository->createNew();
$currency->setCode($code);
$currency->setExchangeRate($rate);
}

$this->manager->persist($currency);
if (!empty($managedCurrencies)) {
return;
}

/** @var $currency CurrencyInterface */
$currency = $this->repository->createNew();
$currency->setCode($code);
$currency->setExchangeRate($rate);
$this->manager->persist($currency);
}
}

0 comments on commit 7126baa

Please sign in to comment.