浏览代码

[Form] Moved namespace DataValidator to Validator

Bernhard Schussek 14 年之前
父节点
当前提交
0259d4da1e

+ 6 - 6
src/Symfony/Component/Form/Field.php

@@ -13,7 +13,7 @@ namespace Symfony\Component\Form;
 
 use Symfony\Component\Form\DataTransformer\DataTransformerInterface;
 use Symfony\Component\Form\DataTransformer\TransformationFailedException;
-use Symfony\Component\Form\DataValidator\DataValidatorInterface;
+use Symfony\Component\Form\Validator\FieldValidatorInterface;
 use Symfony\Component\Form\Renderer\RendererInterface;
 use Symfony\Component\Form\Renderer\Plugin\RendererPluginInterface;
 use Symfony\Component\Form\Event\DataEvent;
@@ -65,7 +65,7 @@ class Field implements FieldInterface
     private $normTransformer;
     private $clientTransformer;
     private $transformationSuccessful = true;
-    private $dataValidator;
+    private $validator;
     private $renderer;
     private $disabled = false;
     private $dispatcher;
@@ -74,7 +74,7 @@ class Field implements FieldInterface
     public function __construct($name, EventDispatcherInterface $dispatcher,
         RendererInterface $renderer, DataTransformerInterface $clientTransformer = null,
         DataTransformerInterface $normTransformer = null,
-        DataValidatorInterface $dataValidator = null, $required = false,
+        FieldValidatorInterface $validator = null, $required = false,
         $disabled = false, array $attributes = array())
     {
         $this->name = (string)$name;
@@ -82,7 +82,7 @@ class Field implements FieldInterface
         $this->renderer = $renderer;
         $this->clientTransformer = $clientTransformer;
         $this->normTransformer = $normTransformer;
-        $this->dataValidator = $dataValidator;
+        $this->validator = $validator;
         $this->required = $required;
         $this->disabled = $disabled;
         $this->attributes = $attributes;
@@ -276,8 +276,8 @@ class Field implements FieldInterface
         $event = new DataEvent($this, $clientData);
         $this->dispatcher->dispatch(Events::postBind, $event);
 
-        if ($this->dataValidator) {
-            $this->dataValidator->validate($this);
+        if ($this->validator) {
+            $this->validator->validate($this);
         }
     }
 

+ 7 - 7
src/Symfony/Component/Form/FieldBuilder.php

@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\Form;
 
-use Symfony\Component\Form\DataValidator\DataValidatorInterface;
+use Symfony\Component\Form\Validator\FieldValidatorInterface;
 use Symfony\Component\Form\DataTransformer\DataTransformerInterface;
 use Symfony\Component\Form\Renderer\DefaultRenderer;
 use Symfony\Component\Form\Renderer\RendererInterface;
@@ -44,7 +44,7 @@ class FieldBuilder
 
     private $theme;
 
-    private $dataValidator;
+    private $validator;
 
     private $attributes = array();
 
@@ -120,14 +120,14 @@ class FieldBuilder
         return $this->required;
     }
 
-    public function setDataValidator(DataValidatorInterface $dataValidator)
+    public function setValidator(FieldValidatorInterface $validator)
     {
-        $this->dataValidator = $dataValidator;
+        $this->validator = $validator;
     }
 
-    public function getDataValidator()
+    public function getValidator()
     {
-        return $this->dataValidator;
+        return $this->validator;
     }
 
     /**
@@ -267,7 +267,7 @@ class FieldBuilder
             $this->buildRenderer(),
             $this->getClientTransformer(),
             $this->getNormTransformer(),
-            $this->getDataValidator(),
+            $this->getValidator(),
             $this->getRequired(),
             $this->getDisabled(),
             $this->getAttributes()

+ 3 - 3
src/Symfony/Component/Form/Form.php

@@ -25,7 +25,7 @@ use Symfony\Component\Form\Exception\FieldDefinitionException;
 use Symfony\Component\Form\CsrfProvider\CsrfProviderInterface;
 use Symfony\Component\Form\DataTransformer\DataTransformerInterface;
 use Symfony\Component\Form\DataMapper\DataMapperInterface;
-use Symfony\Component\Form\DataValidator\DataValidatorInterface;
+use Symfony\Component\Form\Validator\FieldValidatorInterface;
 use Symfony\Component\Form\Renderer\RendererInterface;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -64,7 +64,7 @@ class Form extends Field implements \IteratorAggregate, FormInterface
     public function __construct($name, EventDispatcherInterface $dispatcher,
         RendererInterface $renderer, DataTransformerInterface $clientTransformer = null,
         DataTransformerInterface $normalizationTransformer = null,
-        DataMapperInterface $dataMapper, DataValidatorInterface $dataValidator = null,
+        DataMapperInterface $dataMapper, FieldValidatorInterface $validator = null,
         $required = false, $disabled = false, array $attributes = array())
     {
         $dispatcher->addListener(array(
@@ -77,7 +77,7 @@ class Form extends Field implements \IteratorAggregate, FormInterface
         $this->dataMapper = $dataMapper;
 
         parent::__construct($name, $dispatcher, $renderer, $clientTransformer,
-            $normalizationTransformer, $dataValidator, $required, $disabled,
+            $normalizationTransformer, $validator, $required, $disabled,
             $attributes);
     }
 

+ 1 - 1
src/Symfony/Component/Form/FormBuilder.php

@@ -251,7 +251,7 @@ class FormBuilder extends FieldBuilder
             $this->getClientTransformer(),
             $this->getNormTransformer(),
             $this->getDataMapper(),
-            $this->getDataValidator(),
+            $this->getValidator(),
             $this->getRequired(),
             $this->getDisabled(),
             $this->getAttributes()

+ 2 - 2
src/Symfony/Component/Form/Type/CsrfFieldType.php

@@ -15,7 +15,7 @@ use Symfony\Component\Form\FieldInterface;
 use Symfony\Component\Form\FieldBuilder;
 use Symfony\Component\Form\FieldError;
 use Symfony\Component\Form\CsrfProvider\CsrfProviderInterface;
-use Symfony\Component\Form\DataValidator\CallbackValidator;
+use Symfony\Component\Form\Validator\CallbackValidator;
 
 class CsrfFieldType extends AbstractFieldType
 {
@@ -33,7 +33,7 @@ class CsrfFieldType extends AbstractFieldType
 
         $builder
             ->setData($csrfProvider->generateCsrfToken($pageId))
-            ->setDataValidator(new CallbackValidator(
+            ->setValidator(new CallbackValidator(
                 function (FieldInterface $field) use ($csrfProvider, $pageId) {
                     if (!$csrfProvider->isCsrfTokenValid($pageId, $field->getData())) {
                         // FIXME this error is currently not displayed

+ 2 - 2
src/Symfony/Component/Form/Type/FieldType.php

@@ -19,7 +19,7 @@ use Symfony\Component\Form\Renderer\Plugin\FieldPlugin;
 use Symfony\Component\Form\EventListener\TrimListener;
 use Symfony\Component\Form\EventListener\ValidationListener;
 use Symfony\Component\Form\CsrfProvider\CsrfProviderInterface;
-use Symfony\Component\Form\DataValidator\DelegatingValidator;
+use Symfony\Component\Form\Validator\DelegatingValidator;
 use Symfony\Component\EventDispatcher\EventDispatcher;
 use Symfony\Component\Validator\ValidatorInterface;
 
@@ -59,7 +59,7 @@ class FieldType extends AbstractFieldType
             ->setData($options['data'])
             ->setRenderer(new DefaultRenderer($this->theme, $options['template']))
             ->addRendererPlugin(new FieldPlugin())
-            ->setDataValidator(new DelegatingValidator($this->validator));
+            ->setValidator(new DelegatingValidator($this->validator));
 
         if ($options['trim']) {
             $builder->addEventSubscriber(new TrimListener());

+ 2 - 2
src/Symfony/Component/Form/DataValidator/CallbackValidator.php

@@ -9,11 +9,11 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Component\Form\DataValidator;
+namespace Symfony\Component\Form\Validator;
 
 use Symfony\Component\Form\FieldInterface;
 
-class CallbackValidator implements DataValidatorInterface
+class CallbackValidator implements FieldValidatorInterface
 {
     private $callback;
 

+ 2 - 2
src/Symfony/Component/Form/DataValidator/DelegatingValidator.php

@@ -9,7 +9,7 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Component\Form\DataValidator;
+namespace Symfony\Component\Form\Validator;
 
 use Symfony\Component\Form\FieldInterface;
 use Symfony\Component\Form\FormInterface;
@@ -20,7 +20,7 @@ use Symfony\Component\Form\PropertyPath;
 use Symfony\Component\Form\PropertyPathIterator;
 use Symfony\Component\Validator\ValidatorInterface;
 
-class DelegatingValidator implements DataValidatorInterface
+class DelegatingValidator implements FieldValidatorInterface
 {
     private $validator;
 

+ 2 - 2
src/Symfony/Component/Form/DataValidator/DataValidatorInterface.php

@@ -9,11 +9,11 @@
  * file that was distributed with this source code.
  */
 
-namespace Symfony\Component\Form\DataValidator;
+namespace Symfony\Component\Form\Validator;
 
 use Symfony\Component\Form\FieldInterface;
 
-interface DataValidatorInterface
+interface FieldValidatorInterface
 {
     function validate(FieldInterface $field);
 }