This commit is contained in:
Manuel Raynaud
2013-09-11 08:27:40 +02:00
parent 990ab0e094
commit 70d93d1daa
155 changed files with 541 additions and 809 deletions

View File

@@ -23,7 +23,6 @@
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Model\CurrencyQuery;
@@ -60,7 +59,6 @@ class Currency extends BaseAction implements EventSubscriberInterface
->save()
;
$event->setCurrency($currency);
}
@@ -136,16 +134,15 @@ class Currency extends BaseAction implements EventSubscriberInterface
}
}
public function updateRates() {
public function updateRates()
{
$rates_url = ConfigQuery::read('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');
$rate_data = @file_get_contents($rates_url);
if ($rate_data && $sxe = new \SimpleXMLElement($rate_data)) {
foreach ($sxe->Cube[0]->Cube[0]->Cube as $last)
{
foreach ($sxe->Cube[0]->Cube[0]->Cube as $last) {
$code = strtoupper($last["currency"]);
$rate = floatval($last['rate']);
@@ -157,8 +154,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
;
}
}
}
else {
} else {
throw new \RuntimeException(sprintf("Failed to get currency rates data from URL %s", $rates_url));
}
}