I am new to Symfony(using version 2.2) and trying to add a custom exception listener. I have read the following links but cannot get it to work.
I just had to add \ and the global scope worked in a Symfony service
namespace App\CoreBundle\Service;
class CurrencyExchange
{
const RATES_XML = 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml?849b4b329863b2d60bfd0de486e423c9';
const RATES_XML_PATH = 'uploads/ecb_currencies.xml';
/** @var array $rates */
private $rates;
public function __construct()
{
if (!is_file(self::RATES_XML_PATH)) {
throw new \Exception('XML '.self::RATES_XML_PATH.' does not exists.');
}
if (1 > filesize(self::RATES_XML_PATH)) {
throw new \Exception('XML '.self::RATES_XML_PATH.' is empty.');
}