From 627e476eb4d120cf066cd2bcb890455761a4f823 Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Sat, 2 May 2020 10:52:09 -0400 Subject: [PATCH] [Translations] Throw exception if xFileLoader dependencies don't exist. --- src/Symfony/Component/Translation/Loader/QtFileLoader.php | 5 +++++ src/Symfony/Component/Translation/Loader/XliffFileLoader.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Symfony/Component/Translation/Loader/QtFileLoader.php b/src/Symfony/Component/Translation/Loader/QtFileLoader.php index f5cdec6972..aa89e03978 100644 --- a/src/Symfony/Component/Translation/Loader/QtFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/QtFileLoader.php @@ -15,6 +15,7 @@ use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\Translation\Exception\InvalidResourceException; use Symfony\Component\Translation\Exception\NotFoundResourceException; +use Symfony\Component\Translation\Exception\RuntimeException; use Symfony\Component\Translation\MessageCatalogue; /** @@ -29,6 +30,10 @@ class QtFileLoader implements LoaderInterface */ public function load($resource, string $locale, string $domain = 'messages') { + if (!class_exists(XmlUtils::class)) { + throw new RuntimeException('Loading translations from the QT format requires the Symfony Config component.'); + } + if (!stream_is_local($resource)) { throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource)); } diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 9274a70793..6ea9527dcc 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -15,6 +15,7 @@ use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\Translation\Exception\InvalidResourceException; use Symfony\Component\Translation\Exception\NotFoundResourceException; +use Symfony\Component\Translation\Exception\RuntimeException; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Util\XliffUtils; @@ -30,6 +31,10 @@ class XliffFileLoader implements LoaderInterface */ public function load($resource, string $locale, string $domain = 'messages') { + if (!class_exists(XmlUtils::class)) { + throw new RuntimeException('Loading translations from the Xliff format requires the Symfony Config component.'); + } + if (!stream_is_local($resource)) { throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource)); }