feature #20012 [Translation] added Base Exception for the component. (aitboudad)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[Translation] added Base Exception for the component.

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

Commits
-------

0fa4397 [Translation] added Base Exception for the component.
This commit is contained in:
Fabien Potencier 2016-09-21 10:50:29 -07:00
commit 7f1f23257d
24 changed files with 136 additions and 51 deletions

View File

@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Component\Translation\Translator as BaseTranslator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* Translator.
@ -51,7 +52,7 @@ class Translator extends BaseTranslator implements WarmableInterface
* @param array $loaderIds An array of loader Ids
* @param array $options An array of options
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = array(), array $options = array())
{
@ -60,7 +61,7 @@ class Translator extends BaseTranslator implements WarmableInterface
// check option names
if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
throw new \InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
throw new InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
}
$this->options = array_merge($this->options, $options);

View File

@ -13,6 +13,8 @@ namespace Symfony\Component\Translation\Catalogue;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\MessageCatalogueInterface;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\Exception\LogicException;
/**
* Base catalogues binary operation class.
@ -72,12 +74,12 @@ abstract class AbstractOperation implements OperationInterface
* @param MessageCatalogueInterface $source The source catalogue
* @param MessageCatalogueInterface $target The target catalogue
*
* @throws \LogicException
* @throws LogicException
*/
public function __construct(MessageCatalogueInterface $source, MessageCatalogueInterface $target)
{
if ($source->getLocale() !== $target->getLocale()) {
throw new \LogicException('Operated catalogues must belong to the same locale.');
throw new LogicException('Operated catalogues must belong to the same locale.');
}
$this->source = $source;
@ -105,7 +107,7 @@ abstract class AbstractOperation implements OperationInterface
public function getMessages($domain)
{
if (!in_array($domain, $this->getDomains())) {
throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
}
if (!isset($this->messages[$domain]['all'])) {
@ -121,7 +123,7 @@ abstract class AbstractOperation implements OperationInterface
public function getNewMessages($domain)
{
if (!in_array($domain, $this->getDomains())) {
throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
}
if (!isset($this->messages[$domain]['new'])) {
@ -137,7 +139,7 @@ abstract class AbstractOperation implements OperationInterface
public function getObsoleteMessages($domain)
{
if (!in_array($domain, $this->getDomains())) {
throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
}
if (!isset($this->messages[$domain]['obsolete'])) {

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Translation;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*/
@ -36,7 +38,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
public function __construct(TranslatorInterface $translator)
{
if (!$translator instanceof TranslatorBagInterface) {
throw new \InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator)));
throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator)));
}
$this->translator = $translator;

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Translation\Dumper;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* FileDumper is an implementation of DumperInterface that dump a message catalogue to file(s).
@ -64,7 +65,7 @@ abstract class FileDumper implements DumperInterface
public function dump(MessageCatalogue $messages, $options = array())
{
if (!array_key_exists('path', $options)) {
throw new \InvalidArgumentException('The file dumper needs a path option.');
throw new InvalidArgumentException('The file dumper needs a path option.');
}
// save a file for each domain
@ -79,7 +80,7 @@ abstract class FileDumper implements DumperInterface
} else {
$directory = dirname($fullpath);
if (!file_exists($directory) && !@mkdir($directory, 0777, true)) {
throw new \RuntimeException(sprintf('Unable to create directory "%s".', $directory));
throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory));
}
}
// save file

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Translation\Dumper;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* XliffFileDumper generates xliff files from a message catalogue.
@ -43,7 +44,7 @@ class XliffFileDumper extends FileDumper
return $this->dumpXliff2($defaultLocale, $messages, $domain, $options);
}
throw new \InvalidArgumentException(sprintf('No support implemented for dumping XLIFF version "%s".', $xliffVersion));
throw new InvalidArgumentException(sprintf('No support implemented for dumping XLIFF version "%s".', $xliffVersion));
}
/**

View File

@ -14,6 +14,7 @@ namespace Symfony\Component\Translation\Dumper;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Util\ArrayConverter;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Translation\Exception\LogicException;
/**
* YamlFileDumper generates yaml files from a message catalogue.
@ -28,7 +29,7 @@ class YamlFileDumper extends FileDumper
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
{
if (!class_exists('Symfony\Component\Yaml\Yaml')) {
throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
}
$data = $messages->all($domain);

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Exception;
/**
* Base InvalidArgumentException for the Translation component.
*
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*/
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Exception;
/**
* Base LogicException for Translation component.
*
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*/
class LogicException extends \LogicException implements ExceptionInterface
{
}

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Exception;
/**
* Base RuntimeException for the Translation component.
*
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Translation\Extractor;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* Base class used by classes that extract translation messages from files.
*
@ -56,12 +58,12 @@ abstract class AbstractFileExtractor
*
* @return bool
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
protected function isFile($file)
{
if (!is_file($file)) {
throw new \InvalidArgumentException(sprintf('The "%s" file does not exist.', $file));
throw new InvalidArgumentException(sprintf('The "%s" file does not exist.', $file));
}
return true;

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Translation;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* Tests if a given number belongs to a given math interval.
*
@ -41,14 +43,14 @@ class Interval
*
* @return bool
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public static function test($number, $interval)
{
$interval = trim($interval);
if (!preg_match('/^'.self::getIntervalRegexp().'$/x', $interval, $matches)) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid interval.', $interval));
throw new InvalidArgumentException(sprintf('"%s" is not a valid interval.', $interval));
}
if ($matches[1]) {

View File

@ -15,6 +15,7 @@ use Symfony\Component\Config\Util\XmlUtils;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Config\Resource\FileResource;
/**
@ -202,7 +203,7 @@ class XliffFileLoader implements LoaderInterface
$schemaSource = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-2.0.xsd');
$xmlUri = 'informativeCopiesOf3rdPartySchemas/w3c/xml.xsd';
} else {
throw new \InvalidArgumentException(sprintf('No support implemented for loading XLIFF version "%s".', $xliffVersion));
throw new InvalidArgumentException(sprintf('No support implemented for loading XLIFF version "%s".', $xliffVersion));
}
return $this->fixXmlLocation($schemaSource, $xmlUri);
@ -267,7 +268,7 @@ class XliffFileLoader implements LoaderInterface
*
* @param \DOMDocument $dom
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*
* @return string
*/
@ -283,7 +284,7 @@ class XliffFileLoader implements LoaderInterface
$namespace = $xliff->attributes->getNamedItem('xmlns');
if ($namespace) {
if (substr_compare('urn:oasis:names:tc:xliff:document:', $namespace->nodeValue, 0, 34) !== 0) {
throw new \InvalidArgumentException(sprintf('Not a valid XLIFF namespace "%s"', $namespace));
throw new InvalidArgumentException(sprintf('Not a valid XLIFF namespace "%s"', $namespace));
}
return substr($namespace, 34);

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Translation\Loader;
use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Exception\LogicException;
use Symfony\Component\Yaml\Parser as YamlParser;
use Symfony\Component\Yaml\Exception\ParseException;
@ -31,7 +32,7 @@ class YamlFileLoader extends FileLoader
{
if (null === $this->yamlParser) {
if (!class_exists('Symfony\Component\Yaml\Parser')) {
throw new \LogicException('Loading translations from the YAML format requires the Symfony Yaml component.');
throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.');
}
$this->yamlParser = new YamlParser();

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Translation;
use Psr\Log\LoggerInterface;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
@ -35,7 +36,7 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface
public function __construct(TranslatorInterface $translator, LoggerInterface $logger)
{
if (!$translator instanceof TranslatorBagInterface) {
throw new \InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator)));
throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', get_class($translator)));
}
$this->translator = $translator;

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Translation;
use Symfony\Component\Config\Resource\ResourceInterface;
use Symfony\Component\Translation\Exception\LogicException;
/**
* MessageCatalogue.
@ -143,7 +144,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
public function addCatalogue(MessageCatalogueInterface $catalogue)
{
if ($catalogue->getLocale() !== $this->locale) {
throw new \LogicException(sprintf('Cannot add a catalogue for locale "%s" as the current locale for this catalogue is "%s"', $catalogue->getLocale(), $this->locale));
throw new LogicException(sprintf('Cannot add a catalogue for locale "%s" as the current locale for this catalogue is "%s"', $catalogue->getLocale(), $this->locale));
}
foreach ($catalogue->all() as $domain => $messages) {
@ -169,14 +170,14 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
$c = $catalogue;
while ($c = $c->getFallbackCatalogue()) {
if ($c->getLocale() === $this->getLocale()) {
throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
}
}
$c = $this;
do {
if ($c->getLocale() === $catalogue->getLocale()) {
throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
}
} while ($c = $c->parent);

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Translation;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* MessageSelector.
*
@ -43,7 +45,7 @@ class MessageSelector
*
* @return string
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function choose($message, $number, $locale)
{
@ -78,7 +80,7 @@ class MessageSelector
return $standardRules[0];
}
throw new \InvalidArgumentException(sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $message, $locale, $number));
throw new InvalidArgumentException(sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $message, $locale, $number));
}
return $standardRules[$position];

View File

@ -24,7 +24,7 @@ class IntervalTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testTestException()
{

View File

@ -125,7 +125,7 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \LogicException
* @expectedException \Symfony\Component\Translation\Exception\LogicException
*/
public function testAddFallbackCatalogueWithParentCircularReference()
{
@ -137,7 +137,7 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \LogicException
* @expectedException \Symfony\Component\Translation\Exception\LogicException
*/
public function testAddFallbackCatalogueWithFallbackCircularReference()
{
@ -151,7 +151,7 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \LogicException
* @expectedException \Symfony\Component\Translation\Exception\LogicException
*/
public function testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne()
{

View File

@ -34,7 +34,7 @@ class MessageSelectorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getNonMatchingMessages
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number)
{

View File

@ -20,7 +20,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getInvalidLocalesTests
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testConstructorInvalidLocale($locale)
{
@ -56,7 +56,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getInvalidLocalesTests
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testSetInvalidLocale($locale)
{
@ -139,7 +139,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getInvalidLocalesTests
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testSetFallbackInvalidLocales($locale)
{
@ -170,7 +170,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getInvalidLocalesTests
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testAddResourceInvalidLocales($locale)
{
@ -263,7 +263,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \RuntimeException
* @expectedException \Symfony\Component\Translation\Exception\RuntimeException
*/
public function testWhenAResourceHasNoRegisteredLoader()
{
@ -307,7 +307,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getInvalidLocalesTests
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testTransInvalidLocale($locale)
{
@ -357,7 +357,7 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getInvalidLocalesTests
* @expectedException \InvalidArgumentException
* @expectedException \Symfony\Component\Translation\Exception\InvalidArgumentException
*/
public function testTransChoiceInvalidLocale($locale)
{

View File

@ -13,6 +13,8 @@ namespace Symfony\Component\Translation;
use Symfony\Component\Translation\Loader\LoaderInterface;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\Exception\RuntimeException;
use Symfony\Component\Config\ConfigCacheInterface;
use Symfony\Component\Config\ConfigCacheFactoryInterface;
use Symfony\Component\Config\ConfigCacheFactory;
@ -77,7 +79,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
* @param string|null $cacheDir The directory to use for the cache
* @param bool $debug Use cache in debug mode ?
*
* @throws \InvalidArgumentException If a locale contains invalid characters
* @throws InvalidArgumentException If a locale contains invalid characters
*/
public function __construct($locale, MessageSelector $selector = null, $cacheDir = null, $debug = false)
{
@ -116,7 +118,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
* @param string $locale The locale
* @param string $domain The domain
*
* @throws \InvalidArgumentException If the locale contains invalid characters
* @throws InvalidArgumentException If the locale contains invalid characters
*/
public function addResource($format, $resource, $locale, $domain = null)
{
@ -157,7 +159,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
*
* @param array $locales The fallback locales
*
* @throws \InvalidArgumentException If a locale contains invalid characters
* @throws InvalidArgumentException If a locale contains invalid characters
*/
public function setFallbackLocales(array $locales)
{
@ -371,7 +373,7 @@ EOF
if (isset($this->resources[$locale])) {
foreach ($this->resources[$locale] as $resource) {
if (!isset($this->loaders[$resource[0]])) {
throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0]));
throw new RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0]));
}
$this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));
}
@ -419,12 +421,12 @@ EOF
*
* @param string $locale Locale to tests
*
* @throws \InvalidArgumentException If the locale contains invalid characters
* @throws InvalidArgumentException If the locale contains invalid characters
*/
protected function assertValidLocale($locale)
{
if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
}
}

View File

@ -25,7 +25,7 @@ interface TranslatorBagInterface
*
* @return MessageCatalogueInterface
*
* @throws \InvalidArgumentException If the locale contains invalid characters
* @throws InvalidArgumentException If the locale contains invalid characters
*/
public function getCatalogue($locale = null);
}

View File

@ -28,7 +28,7 @@ interface TranslatorInterface
*
* @return string The translated string
*
* @throws \InvalidArgumentException If the locale contains invalid characters
* @throws InvalidArgumentException If the locale contains invalid characters
*/
public function trans($id, array $parameters = array(), $domain = null, $locale = null);
@ -43,7 +43,7 @@ interface TranslatorInterface
*
* @return string The translated string
*
* @throws \InvalidArgumentException If the locale contains invalid characters
* @throws InvalidArgumentException If the locale contains invalid characters
*/
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null);
@ -52,7 +52,7 @@ interface TranslatorInterface
*
* @param string $locale The locale
*
* @throws \InvalidArgumentException If the locale contains invalid characters
* @throws InvalidArgumentException If the locale contains invalid characters
*/
public function setLocale($locale);

View File

@ -13,6 +13,8 @@ namespace Symfony\Component\Translation\Writer;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Dumper\DumperInterface;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\Exception\RuntimeException;
/**
* TranslationWriter writes translation messages.
@ -68,19 +70,19 @@ class TranslationWriter
* @param string $format The format to use to dump the messages
* @param array $options Options that are passed to the dumper
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function writeTranslations(MessageCatalogue $catalogue, $format, $options = array())
{
if (!isset($this->dumpers[$format])) {
throw new \InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format));
throw new InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format));
}
// get the right dumper
$dumper = $this->dumpers[$format];
if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) {
throw new \RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
throw new RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
}
// save