[Form] Introduced base ExceptionInterface
This commit is contained in:
parent
c4a2a2ba2b
commit
fee1bf5448
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Exception\StringCastException;
|
||||
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
@ -387,12 +387,12 @@ class EntityChoiceList extends ObjectChoiceList
|
||||
*
|
||||
* @return array The identifier values
|
||||
*
|
||||
* @throws FormException If the entity does not exist in Doctrine's identity map
|
||||
* @throws Exception If the entity does not exist in Doctrine's identity map
|
||||
*/
|
||||
private function getIdentifierValues($entity)
|
||||
{
|
||||
if (!$this->em->contains($entity)) {
|
||||
throw new FormException(
|
||||
throw new Exception(
|
||||
'Entities passed to the choice field must be managed. Maybe ' .
|
||||
'persist them in the entity manager?'
|
||||
);
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace Symfony\Bridge\Doctrine\Form\Type;
|
||||
|
||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList;
|
||||
@ -134,7 +134,7 @@ abstract class DoctrineType extends AbstractType
|
||||
$em = $registry->getManagerForClass($options['class']);
|
||||
|
||||
if (null === $em) {
|
||||
throw new FormException(sprintf(
|
||||
throw new Exception(sprintf(
|
||||
'Class "%s" seems not to be a managed Doctrine entity. ' .
|
||||
'Did you forget to map it?',
|
||||
$options['class']
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ abstract class AbstractExtension implements FormExtensionInterface
|
||||
}
|
||||
|
||||
if (!isset($this->types[$name])) {
|
||||
throw new FormException(sprintf('The type "%s" can not be loaded by this extension', $name));
|
||||
throw new Exception(sprintf('The type "%s" can not be loaded by this extension', $name));
|
||||
}
|
||||
|
||||
return $this->types[$name];
|
||||
|
@ -9,6 +9,7 @@ CHANGELOG
|
||||
* FormInterface::add() now accepts a FormInterface instance OR a field's name, type and options
|
||||
* removed special characters between the choice or text fields of DateType unless
|
||||
the option "format" is set to a custom value
|
||||
* deprecated FormException and introduced ExceptionInterface instead
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class AlreadyBoundException extends FormException
|
||||
class AlreadyBoundException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ namespace Symfony\Component\Form\Exception;
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class CreationException extends FormException
|
||||
class CreationException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class ErrorMappingException extends FormException
|
||||
class ErrorMappingException extends Exception
|
||||
{
|
||||
}
|
||||
|
26
src/Symfony/Component/Form/Exception/Exception.php
Normal file
26
src/Symfony/Component/Form/Exception/Exception.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?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\Form\Exception;
|
||||
|
||||
/**
|
||||
* Base exception class.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated This class is a replacement for when class FormException was
|
||||
* used previously. It should not be used and will be removed.
|
||||
* Occurrences of this class should be replaced by more specialized
|
||||
* exception classes, preferably derived from SPL exceptions.
|
||||
*/
|
||||
class Exception extends \Exception implements ExceptionInterface
|
||||
{
|
||||
}
|
21
src/Symfony/Component/Form/Exception/ExceptionInterface.php
Normal file
21
src/Symfony/Component/Form/Exception/ExceptionInterface.php
Normal 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\Form\Exception;
|
||||
|
||||
/**
|
||||
* Base ExceptionInterface for the Form component.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface ExceptionInterface extends FormException
|
||||
{
|
||||
}
|
@ -11,6 +11,14 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class FormException extends \Exception
|
||||
/**
|
||||
* Alias of {@link ExceptionInterface}.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @deprecated This interface was deprecated and will be removed in Symfony 2.3.
|
||||
* You should code against {@link ExceptionInterface} instead.
|
||||
*/
|
||||
interface FormException
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class InvalidConfigurationException extends FormException
|
||||
class InvalidConfigurationException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class InvalidPropertyException extends FormException
|
||||
class InvalidPropertyException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class InvalidPropertyPathException extends FormException
|
||||
class InvalidPropertyPathException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class NotInitializedException extends FormException
|
||||
class NotInitializedException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class NotValidException extends FormException
|
||||
class NotValidException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class PropertyAccessDeniedException extends FormException
|
||||
class PropertyAccessDeniedException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class StringCastException extends FormException
|
||||
class StringCastException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ namespace Symfony\Component\Form\Exception;
|
||||
/**
|
||||
* Indicates a value transformation error.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class TransformationFailedException extends \RuntimeException
|
||||
class TransformationFailedException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ namespace Symfony\Component\Form\Exception;
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class TypeDefinitionException extends FormException
|
||||
class TypeDefinitionException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class TypeLoaderException extends FormException
|
||||
class TypeLoaderException extends Exception
|
||||
{
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form\Exception;
|
||||
|
||||
class UnexpectedTypeException extends FormException
|
||||
class UnexpectedTypeException extends Exception
|
||||
{
|
||||
public function __construct($value, $expectedType)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form\Extension\Core\ChoiceList;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
|
||||
/**
|
||||
* A choice list that is loaded lazily
|
||||
@ -141,7 +141,7 @@ abstract class LazyChoiceList implements ChoiceListInterface
|
||||
$choiceList = $this->loadChoiceList();
|
||||
|
||||
if (!$choiceList instanceof ChoiceListInterface) {
|
||||
throw new FormException('loadChoiceList() should return a ChoiceListInterface instance. Got ' . gettype($choiceList));
|
||||
throw new Exception('loadChoiceList() should return a ChoiceListInterface instance. Got ' . gettype($choiceList));
|
||||
}
|
||||
|
||||
$this->choiceList = $choiceList;
|
||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
|
||||
use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener;
|
||||
use Symfony\Component\Form\Extension\Core\EventListener\FixCheckboxInputListener;
|
||||
@ -41,7 +41,7 @@ class ChoiceType extends AbstractType
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
if (!$options['choice_list'] && !is_array($options['choices']) && !$options['choices'] instanceof \Traversable) {
|
||||
throw new FormException('Either the option "choices" or "choice_list" must be set.');
|
||||
throw new Exception('Either the option "choices" or "choice_list" must be set.');
|
||||
}
|
||||
|
||||
if ($options['expanded']) {
|
||||
|
@ -17,7 +17,7 @@ use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
|
||||
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
@ -61,7 +61,7 @@ class FormType extends AbstractType
|
||||
|
||||
if ($view->parent) {
|
||||
if ('' === $name) {
|
||||
throw new FormException('Form node with empty name can be used only as root form node.');
|
||||
throw new Exception('Form node with empty name can be used only as root form node.');
|
||||
}
|
||||
|
||||
if ('' !== ($parentFullName = $view->parent->vars['full_name'])) {
|
||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\Form\Extension\HttpFoundation\EventListener;
|
||||
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
@ -74,7 +74,7 @@ class BindRequestListener implements EventSubscriberInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new FormException(sprintf(
|
||||
throw new Exception(sprintf(
|
||||
'The request method "%s" is not supported',
|
||||
$request->getMethod()
|
||||
));
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Exception\AlreadyBoundException;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
@ -152,7 +152,7 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
// `setData` and `add` will not lead to the correct population of
|
||||
// the child forms.
|
||||
if ($config->getCompound() && !$config->getDataMapper()) {
|
||||
throw new FormException('Compound forms need a data mapper');
|
||||
throw new Exception('Compound forms need a data mapper');
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
@ -256,7 +256,7 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
}
|
||||
|
||||
if (null !== $parent && '' === $this->config->getName()) {
|
||||
throw new FormException('A form with an empty name cannot have a parent form.');
|
||||
throw new Exception('A form with an empty name cannot have a parent form.');
|
||||
}
|
||||
|
||||
$this->parent = $parent;
|
||||
@ -359,7 +359,7 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
}
|
||||
|
||||
if ($this->lockSetData) {
|
||||
throw new FormException('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.');
|
||||
throw new Exception('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.');
|
||||
}
|
||||
|
||||
$this->lockSetData = true;
|
||||
@ -394,7 +394,7 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
if (null === $dataClass && is_object($viewData) && !$viewData instanceof \ArrayAccess) {
|
||||
$expectedType = 'scalar, array or an instance of \ArrayAccess';
|
||||
|
||||
throw new FormException(
|
||||
throw new Exception(
|
||||
'The form\'s view data is expected to be of type ' . $expectedType . ', ' .
|
||||
'but is ' . $actualType . '. You ' .
|
||||
'can avoid this error by setting the "data_class" option to ' .
|
||||
@ -404,7 +404,7 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
}
|
||||
|
||||
if (null !== $dataClass && !$viewData instanceof $dataClass) {
|
||||
throw new FormException(
|
||||
throw new Exception(
|
||||
'The form\'s view data is expected to be an instance of class ' .
|
||||
$dataClass . ', but is '. $actualType . '. You can avoid this error ' .
|
||||
'by setting the "data_class" option to null or by adding a view ' .
|
||||
@ -867,7 +867,7 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
}
|
||||
|
||||
if (!$this->config->getCompound()) {
|
||||
throw new FormException('You cannot add children to a simple form. Maybe you should set the option "compound" to true?');
|
||||
throw new Exception('You cannot add children to a simple form. Maybe you should set the option "compound" to true?');
|
||||
}
|
||||
|
||||
// Obtain the view data
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
@ -65,7 +65,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
|
||||
public function add($child, $type = null, array $options = array())
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The form builder cannot be modified anymore.');
|
||||
throw new Exception('The form builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
if ($child instanceof self) {
|
||||
@ -102,7 +102,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
|
||||
public function create($name, $type = null, array $options = array())
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The form builder cannot be modified anymore.');
|
||||
throw new Exception('The form builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
if (null === $type && null === $this->getDataClass()) {
|
||||
@ -129,7 +129,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
|
||||
return $this->children[$name];
|
||||
}
|
||||
|
||||
throw new FormException(sprintf('The child with the name "%s" does not exist.', $name));
|
||||
throw new Exception(sprintf('The child with the name "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
|
||||
public function remove($name)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The form builder cannot be modified anymore.');
|
||||
throw new Exception('The form builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
unset($this->unresolvedChildren[$name]);
|
||||
@ -217,7 +217,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
|
||||
public function setParent(FormBuilderInterface $parent = null)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The form builder cannot be modified anymore.');
|
||||
throw new Exception('The form builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->parent = $parent;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Util\PropertyPath;
|
||||
use Symfony\Component\Form\Util\PropertyPathInterface;
|
||||
@ -172,7 +172,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function addEventListener($eventName, $listener, $priority = 0)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->dispatcher->addListener($eventName, $listener, $priority);
|
||||
@ -186,7 +186,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function addEventSubscriber(EventSubscriberInterface $subscriber)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->dispatcher->addSubscriber($subscriber);
|
||||
@ -202,7 +202,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
trigger_error('addValidator() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
|
||||
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->validators[] = $validator;
|
||||
@ -216,7 +216,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
if ($forcePrepend) {
|
||||
@ -234,7 +234,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function resetViewTransformers()
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->viewTransformers = array();
|
||||
@ -249,7 +249,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*
|
||||
* @return FormConfigBuilder The configuration object.
|
||||
*
|
||||
* @throws FormException if the form configuration is locked
|
||||
* @throws Exception if the form configuration is locked
|
||||
*
|
||||
* @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
||||
* {@link addViewTransformer()} instead.
|
||||
@ -259,7 +259,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
trigger_error('appendClientTransformer() is deprecated since version 2.1 and will be removed in 2.3. Use addViewTransformer() instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
return $this->addViewTransformer($viewTransformer);
|
||||
@ -272,7 +272,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*
|
||||
* @return FormConfigBuilder The configuration object.
|
||||
*
|
||||
* @throws FormException if the form configuration is locked
|
||||
* @throws Exception if the form configuration is locked
|
||||
*
|
||||
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
|
||||
*/
|
||||
@ -281,7 +281,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
trigger_error('prependClientTransformer() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
|
||||
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
return $this->addViewTransformer($viewTransformer, true);
|
||||
@ -292,7 +292,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*
|
||||
* @return FormConfigBuilder The configuration object.
|
||||
*
|
||||
* @throws FormException if the form configuration is locked
|
||||
* @throws Exception if the form configuration is locked
|
||||
*
|
||||
* @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
||||
* {@link resetViewTransformers()} instead.
|
||||
@ -302,7 +302,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
trigger_error('resetClientTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use resetViewTransformers() instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
return $this->resetViewTransformers();
|
||||
@ -314,7 +314,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
if ($forceAppend) {
|
||||
@ -332,7 +332,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function resetModelTransformers()
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->modelTransformers = array();
|
||||
@ -347,7 +347,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*
|
||||
* @return FormConfigBuilder The configuration object.
|
||||
*
|
||||
* @throws FormException if the form configuration is locked
|
||||
* @throws Exception if the form configuration is locked
|
||||
*
|
||||
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
|
||||
*/
|
||||
@ -356,7 +356,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
trigger_error('appendNormTransformer() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
|
||||
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
return $this->addModelTransformer($modelTransformer, true);
|
||||
@ -369,7 +369,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*
|
||||
* @return FormConfigBuilder The configuration object.
|
||||
*
|
||||
* @throws FormException if the form configuration is locked
|
||||
* @throws Exception if the form configuration is locked
|
||||
*
|
||||
* @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
||||
* {@link addModelTransformer()} instead.
|
||||
@ -379,7 +379,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
trigger_error('prependNormTransformer() is deprecated since version 2.1 and will be removed in 2.3. Use addModelTransformer() instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
return $this->addModelTransformer($modelTransformer);
|
||||
@ -390,7 +390,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*
|
||||
* @return FormConfigBuilder The configuration object.
|
||||
*
|
||||
* @throws FormException if the form configuration is locked
|
||||
* @throws Exception if the form configuration is locked
|
||||
*
|
||||
* @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
||||
* {@link resetModelTransformers()} instead.
|
||||
@ -400,7 +400,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
trigger_error('resetNormTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use resetModelTransformers() instead.', E_USER_DEPRECATED);
|
||||
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
return $this->resetModelTransformers();
|
||||
@ -652,7 +652,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setAttribute($name, $value)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->attributes[$name] = $value;
|
||||
@ -666,7 +666,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setAttributes(array $attributes)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->attributes = $attributes;
|
||||
@ -680,7 +680,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setDataMapper(DataMapperInterface $dataMapper = null)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->dataMapper = $dataMapper;
|
||||
@ -694,7 +694,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setDisabled($disabled)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->disabled = (Boolean) $disabled;
|
||||
@ -708,7 +708,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setEmptyData($emptyData)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->emptyData = $emptyData;
|
||||
@ -722,7 +722,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setErrorBubbling($errorBubbling)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->errorBubbling = null === $errorBubbling ? null : (Boolean) $errorBubbling;
|
||||
@ -736,7 +736,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setRequired($required)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->required = (Boolean) $required;
|
||||
@ -750,7 +750,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setPropertyPath($propertyPath)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
if (null !== $propertyPath && !$propertyPath instanceof PropertyPathInterface) {
|
||||
@ -768,7 +768,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setMapped($mapped)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->mapped = $mapped;
|
||||
@ -782,7 +782,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setByReference($byReference)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->byReference = $byReference;
|
||||
@ -796,7 +796,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setVirtual($virtual)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->virtual = $virtual;
|
||||
@ -810,7 +810,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setCompound($compound)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->compound = $compound;
|
||||
@ -824,7 +824,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setType(ResolvedFormTypeInterface $type)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
@ -838,7 +838,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setData($data)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->data = $data;
|
||||
@ -852,7 +852,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setDataLocked($locked)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->dataLocked = $locked;
|
||||
@ -866,7 +866,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
public function setFormFactory(FormFactoryInterface $formFactory)
|
||||
{
|
||||
if ($this->locked) {
|
||||
throw new FormException('The config builder cannot be modified anymore.');
|
||||
throw new Exception('The config builder cannot be modified anymore.');
|
||||
}
|
||||
|
||||
$this->formFactory = $formFactory;
|
||||
|
@ -11,8 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
|
||||
/**
|
||||
* The central registry of the Form component.
|
||||
@ -95,7 +96,7 @@ class FormRegistry implements FormRegistryInterface
|
||||
}
|
||||
|
||||
if (!$type) {
|
||||
throw new FormException(sprintf('Could not load type "%s"', $name));
|
||||
throw new Exception(sprintf('Could not load type "%s"', $name));
|
||||
}
|
||||
|
||||
$this->resolveAndAddType($type);
|
||||
@ -151,7 +152,7 @@ class FormRegistry implements FormRegistryInterface
|
||||
|
||||
try {
|
||||
$this->getType($name);
|
||||
} catch (FormException $e) {
|
||||
} catch (ExceptionInterface $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
|
||||
|
||||
/**
|
||||
@ -88,7 +88,7 @@ class FormRenderer implements FormRendererInterface
|
||||
public function renderBlock(FormView $view, $blockName, array $variables = array())
|
||||
{
|
||||
if (0 == count($this->variableStack)) {
|
||||
throw new FormException('This method should only be called while rendering a form element.');
|
||||
throw new Exception('This method should only be called while rendering a form element.');
|
||||
}
|
||||
|
||||
$viewCacheKey = $view->vars[self::CACHE_KEY_VAR];
|
||||
@ -97,7 +97,7 @@ class FormRenderer implements FormRendererInterface
|
||||
$resource = $this->engine->getResourceForBlockName($view, $blockName);
|
||||
|
||||
if (!$resource) {
|
||||
throw new FormException(sprintf('No block "%s" found while rendering the form.', $blockName));
|
||||
throw new Exception(sprintf('No block "%s" found while rendering the form.', $blockName));
|
||||
}
|
||||
|
||||
// Merge the passed with the existing attributes
|
||||
@ -217,7 +217,7 @@ class FormRenderer implements FormRendererInterface
|
||||
|
||||
// Escape if no resource exists for this block
|
||||
if (!$resource) {
|
||||
throw new FormException(sprintf(
|
||||
throw new Exception(sprintf(
|
||||
'Unable to render the form as none of the following blocks exist: "%s".',
|
||||
implode('", "', array_reverse($blockNameHierarchy))
|
||||
));
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
|
||||
/**
|
||||
* A form extension with preloaded types, type exceptions and type guessers.
|
||||
@ -55,7 +55,7 @@ class PreloadedExtension implements FormExtensionInterface
|
||||
public function getType($name)
|
||||
{
|
||||
if (!isset($this->types[$name])) {
|
||||
throw new FormException(sprintf('The type "%s" can not be loaded by this extension', $name));
|
||||
throw new Exception(sprintf('The type "%s" can not be loaded by this extension', $name));
|
||||
}
|
||||
|
||||
return $this->types[$name];
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Form\Exception\FormException;
|
||||
use Symfony\Component\Form\Exception\Exception;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -46,7 +46,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
|
||||
public function __construct(FormTypeInterface $innerType, array $typeExtensions = array(), ResolvedFormTypeInterface $parent = null)
|
||||
{
|
||||
if (!preg_match('/^[a-z0-9_]*$/i', $innerType->getName())) {
|
||||
throw new FormException(sprintf(
|
||||
throw new Exception(sprintf(
|
||||
'The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".',
|
||||
get_class($innerType),
|
||||
$innerType->getName()
|
||||
|
@ -82,7 +82,7 @@ class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testLoadChoiceListShouldReturnChoiceList()
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ class ObjectChoiceListTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testInitArrayThrowsExceptionIfToStringNotFound()
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ class ChoiceTypeTest extends TypeTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testEitherChoiceListOrChoicesMustBeSet()
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGetUnknown()
|
||||
{
|
||||
$this->setExpectedException('Symfony\Component\Form\Exception\FormException', 'The child with the name "foo" does not exist.');
|
||||
$this->setExpectedException('Symfony\Component\Form\Exception\Exception', 'The child with the name "foo" does not exist.');
|
||||
$this->builder->get('foo');
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testGetTypeThrowsExceptionIfParentNotFound()
|
||||
{
|
||||
@ -200,7 +200,7 @@ class FormRegistryTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testGetTypeThrowsExceptionIfTypeNotFound()
|
||||
{
|
||||
|
@ -741,7 +741,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
* @expectedExceptionMessage A form with an empty name cannot have a parent form.
|
||||
*/
|
||||
public function testFormCannotHaveEmptyNameNotInRootLevel()
|
||||
@ -787,7 +787,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testViewDataMustNotBeObjectIfDataClassIsNull()
|
||||
{
|
||||
@ -817,7 +817,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testViewDataMustBeObjectIfDataClassIsSet()
|
||||
{
|
||||
@ -832,7 +832,7 @@ class SimpleFormTest extends AbstractFormTest
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
||||
* @expectedException \Symfony\Component\Form\Exception\Exception
|
||||
*/
|
||||
public function testSetDataCannotInvokeItself()
|
||||
{
|
||||
|
@ -285,7 +285,7 @@ abstract class PropertyPathCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
try {
|
||||
$path->setValue($car, $axes);
|
||||
$this->fail('An expected exception was not thrown!');
|
||||
} catch (\Symfony\Component\Form\Exception\FormException $e) {
|
||||
} catch (\Symfony\Component\Form\Exception\Exception $e) {
|
||||
$this->assertEquals($message, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user