From cd662ccf7a7d29f0ed15c8fd6a0c2033fd14d709 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Tue, 8 Jan 2013 15:20:14 +0100 Subject: [PATCH] [Validator] Added ExceptionInterface, BadMethodCallException and InvalidArgumentException --- src/Symfony/Component/Validator/CHANGELOG.md | 1 + .../Component/Validator/DefaultTranslator.php | 8 ++++--- .../Exception/BadMethodCallException.php | 21 +++++++++++++++++++ .../Exception/ExceptionInterface.php | 21 +++++++++++++++++++ .../Exception/InvalidArgumentException.php | 21 +++++++++++++++++++ 5 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Component/Validator/Exception/BadMethodCallException.php create mode 100644 src/Symfony/Component/Validator/Exception/ExceptionInterface.php create mode 100644 src/Symfony/Component/Validator/Exception/InvalidArgumentException.php diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index b0f47b233bf6..fa26425aefc9 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -38,6 +38,7 @@ CHANGELOG * [BC BREAK] added `setTranslator()` and `setTranslationDomain()` to `ValidatorBuilderInterface` * improved the Validator to support pluralized messages by default * [BC BREAK] changed the source of all pluralized messages in the translation files to the pluralized version + * added ExceptionInterface, BadMethodCallException and InvalidArgumentException 2.1.0 ----- diff --git a/src/Symfony/Component/Validator/DefaultTranslator.php b/src/Symfony/Component/Validator/DefaultTranslator.php index c46856752d1a..455729bc1614 100644 --- a/src/Symfony/Component/Validator/DefaultTranslator.php +++ b/src/Symfony/Component/Validator/DefaultTranslator.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Validator\Exception\BadMethodCallException; +use Symfony\Component\Validator\Exception\InvalidArgumentException; use Symfony\Component\Translation\TranslatorInterface; /** @@ -43,7 +45,7 @@ public function transChoice($id, $number, array $parameters = array(), $domain = } if (!isset($ids[1])) { - throw new \InvalidArgumentException(sprintf('The message "%s" cannot be pluralized, because it is missing a plural (e.g. "There is one apple|There are %%count%% apples").', $id)); + throw new InvalidArgumentException(sprintf('The message "%s" cannot be pluralized, because it is missing a plural (e.g. "There is one apple|There are %%count%% apples").', $id)); } return strtr($ids[1], $parameters); @@ -54,7 +56,7 @@ public function transChoice($id, $number, array $parameters = array(), $domain = */ public function setLocale($locale) { - throw new \BadMethodCallException('Unsupported method.'); + throw new BadMethodCallException('Unsupported method.'); } /** @@ -62,6 +64,6 @@ public function setLocale($locale) */ public function getLocale() { - throw new \BadMethodCallException('Unsupported method.'); + throw new BadMethodCallException('Unsupported method.'); } } diff --git a/src/Symfony/Component/Validator/Exception/BadMethodCallException.php b/src/Symfony/Component/Validator/Exception/BadMethodCallException.php new file mode 100644 index 000000000000..939161bff3f0 --- /dev/null +++ b/src/Symfony/Component/Validator/Exception/BadMethodCallException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Exception; + +/** + * Base BadMethodCallException for the Validator component. + * + * @author Bernhard Schussek + */ +class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface +{ +} diff --git a/src/Symfony/Component/Validator/Exception/ExceptionInterface.php b/src/Symfony/Component/Validator/Exception/ExceptionInterface.php new file mode 100644 index 000000000000..77d09b9029c2 --- /dev/null +++ b/src/Symfony/Component/Validator/Exception/ExceptionInterface.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Exception; + +/** + * Base ExceptionInterface for the Validator component. + * + * @author Bernhard Schussek + */ +interface ExceptionInterface +{ +} diff --git a/src/Symfony/Component/Validator/Exception/InvalidArgumentException.php b/src/Symfony/Component/Validator/Exception/InvalidArgumentException.php new file mode 100644 index 000000000000..22da39bb262c --- /dev/null +++ b/src/Symfony/Component/Validator/Exception/InvalidArgumentException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Exception; + +/** + * Base InvalidArgumentException for the Validator component. + * + * @author Bernhard Schussek + */ +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +{ +}