[Translation] Make IcuDatFileLoader/IcuResFileLoader::load invalid resource compatible with HHVM.

This commit is contained in:
Ioan Negulescu 2014-04-11 21:33:51 -07:00 committed by Fabien Potencier
parent 73f6c16163
commit 9bc08c0279
4 changed files with 24 additions and 4 deletions

View File

@ -28,7 +28,12 @@ class BinaryBundleReader extends AbstractBundleReader implements BundleReaderInt
{
// Point for future extension: Modify this class so that it works also
// if the \ResourceBundle class is not available.
$bundle = new \ResourceBundle($locale, $path);
try {
$bundle = new \ResourceBundle($locale, $path);
} catch (\Exception $e) {
// HHVM compatibility: constructor throws on invalid resource
$bundle = null;
}
if (null === $bundle) {
throw new RuntimeException(sprintf(

View File

@ -119,7 +119,12 @@ class LocaleBundleTransformationRule implements TransformationRuleInterface
}
// Delete locales that have no content (i.e. only "Version" key)
$bundle = new \ResourceBundle($locale, $tempDir);
try {
$bundle = new \ResourceBundle($locale, $tempDir);
} catch (\Exception $e) {
// HHVM compatibility: constructor throws on invalid resource
$bundle = null;
}
if (null === $bundle) {
throw new RuntimeException('The resource bundle for locale ' . $locale . ' could not be loaded from directory ' . $tempDir);

View File

@ -36,7 +36,12 @@ class IcuDatFileLoader extends IcuResFileLoader
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
}
$rb = new \ResourceBundle($locale, $resource);
try {
$rb = new \ResourceBundle($locale, $resource);
} catch (\Exception $e) {
// HHVM compatibility: constructor throws on invalid resource
$rb = null;
}
if (!$rb) {
throw new InvalidResourceException(sprintf('Cannot load resource "%s"', $resource));

View File

@ -36,7 +36,12 @@ class IcuResFileLoader implements LoaderInterface
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
}
$rb = new \ResourceBundle($locale, $resource);
try {
$rb = new \ResourceBundle($locale, $resource);
} catch (\Exception $e) {
// HHVM compatibility: constructor throws on invalid resource
$rb = null;
}
if (!$rb) {
throw new InvalidResourceException(sprintf('Cannot load resource "%s"', $resource));