[Validator] Added ExceptionInterface, BadMethodCallException and InvalidArgumentException
This commit is contained in:
parent
e00e5ecf4e
commit
cd662ccf7a
@ -38,6 +38,7 @@ CHANGELOG
|
|||||||
* [BC BREAK] added `setTranslator()` and `setTranslationDomain()` to `ValidatorBuilderInterface`
|
* [BC BREAK] added `setTranslator()` and `setTranslationDomain()` to `ValidatorBuilderInterface`
|
||||||
* improved the Validator to support pluralized messages by default
|
* 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
|
* [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
|
2.1.0
|
||||||
-----
|
-----
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator;
|
namespace Symfony\Component\Validator;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Exception\BadMethodCallException;
|
||||||
|
use Symfony\Component\Validator\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +45,7 @@ class DefaultTranslator implements TranslatorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($ids[1])) {
|
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);
|
return strtr($ids[1], $parameters);
|
||||||
@ -54,7 +56,7 @@ class DefaultTranslator implements TranslatorInterface
|
|||||||
*/
|
*/
|
||||||
public function setLocale($locale)
|
public function setLocale($locale)
|
||||||
{
|
{
|
||||||
throw new \BadMethodCallException('Unsupported method.');
|
throw new BadMethodCallException('Unsupported method.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,6 +64,6 @@ class DefaultTranslator implements TranslatorInterface
|
|||||||
*/
|
*/
|
||||||
public function getLocale()
|
public function getLocale()
|
||||||
{
|
{
|
||||||
throw new \BadMethodCallException('Unsupported method.');
|
throw new BadMethodCallException('Unsupported method.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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\Validator\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base BadMethodCallException for the Validator component.
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
|
||||||
|
{
|
||||||
|
}
|
@ -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\Validator\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base ExceptionInterface for the Validator component.
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
interface ExceptionInterface
|
||||||
|
{
|
||||||
|
}
|
@ -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\Validator\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base InvalidArgumentException for the Validator component.
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
|
||||||
|
{
|
||||||
|
}
|
Reference in New Issue
Block a user