improved exception when missing required component
This commit is contained in:
parent
8b7148fbec
commit
c3bd418483
@ -26,6 +26,10 @@ class YamlFileDumper extends FileDumper
|
|||||||
*/
|
*/
|
||||||
protected function format(MessageCatalogue $messages, $domain)
|
protected function format(MessageCatalogue $messages, $domain)
|
||||||
{
|
{
|
||||||
|
if (!class_exists('Symfony\Component\Yaml\Yaml')) {
|
||||||
|
throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
|
||||||
|
}
|
||||||
|
|
||||||
return Yaml::dump($messages->all($domain));
|
return Yaml::dump($messages->all($domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,10 @@ class CsvFileLoader extends ArrayLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
$catalogue = parent::load($messages, $locale, $domain);
|
$catalogue = parent::load($messages, $locale, $domain);
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,10 @@ class IcuDatFileLoader extends IcuResFileLoader
|
|||||||
$messages = $this->flatten($rb);
|
$messages = $this->flatten($rb);
|
||||||
$catalogue = new MessageCatalogue($locale);
|
$catalogue = new MessageCatalogue($locale);
|
||||||
$catalogue->add($messages, $domain);
|
$catalogue->add($messages, $domain);
|
||||||
$catalogue->addResource(new FileResource($resource.'.dat'));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource.'.dat'));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,10 @@ class IcuResFileLoader implements LoaderInterface
|
|||||||
$messages = $this->flatten($rb);
|
$messages = $this->flatten($rb);
|
||||||
$catalogue = new MessageCatalogue($locale);
|
$catalogue = new MessageCatalogue($locale);
|
||||||
$catalogue->add($messages, $domain);
|
$catalogue->add($messages, $domain);
|
||||||
$catalogue->addResource(new DirectoryResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\DirectoryResource')) {
|
||||||
|
$catalogue->addResource(new DirectoryResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,10 @@ class IniFileLoader extends ArrayLoader
|
|||||||
$messages = parse_ini_file($resource, true);
|
$messages = parse_ini_file($resource, true);
|
||||||
|
|
||||||
$catalogue = parent::load($messages, $locale, $domain);
|
$catalogue = parent::load($messages, $locale, $domain);
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,10 @@ class MoFileLoader extends ArrayLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
$catalogue = parent::load($messages, $locale, $domain);
|
$catalogue = parent::load($messages, $locale, $domain);
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,10 @@ class PhpFileLoader extends ArrayLoader
|
|||||||
$messages = require $resource;
|
$messages = require $resource;
|
||||||
|
|
||||||
$catalogue = parent::load($messages, $locale, $domain);
|
$catalogue = parent::load($messages, $locale, $domain);
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,10 @@ class PoFileLoader extends ArrayLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
$catalogue = parent::load($messages, $locale, $domain);
|
$catalogue = parent::load($messages, $locale, $domain);
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,10 @@ class QtFileLoader implements LoaderInterface
|
|||||||
}
|
}
|
||||||
$translation = $translation->nextSibling;
|
$translation = $translation->nextSibling;
|
||||||
}
|
}
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
libxml_use_internal_errors($internalErrors);
|
libxml_use_internal_errors($internalErrors);
|
||||||
|
@ -69,7 +69,10 @@ class XliffFileLoader implements LoaderInterface
|
|||||||
|
|
||||||
$catalogue->set((string) $source, $target, $domain);
|
$catalogue->set((string) $source, $target, $domain);
|
||||||
}
|
}
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,10 @@ class YamlFileLoader extends ArrayLoader
|
|||||||
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
|
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!class_exists('Symfony\Component\Yaml\Parser')) {
|
||||||
|
throw new \LogicException('Loading translations from the YAML format requires the Symfony Yaml component.');
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $this->yamlParser) {
|
if (null === $this->yamlParser) {
|
||||||
$this->yamlParser = new YamlParser();
|
$this->yamlParser = new YamlParser();
|
||||||
}
|
}
|
||||||
@ -64,7 +68,10 @@ class YamlFileLoader extends ArrayLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
$catalogue = parent::load($messages, $locale, $domain);
|
$catalogue = parent::load($messages, $locale, $domain);
|
||||||
$catalogue->addResource(new FileResource($resource));
|
|
||||||
|
if (class_exists('Symfony\Component\Config\Resource\FileResource')) {
|
||||||
|
$catalogue->addResource(new FileResource($resource));
|
||||||
|
}
|
||||||
|
|
||||||
return $catalogue;
|
return $catalogue;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user