Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Calling enableAnnotationMapping without argument is deprecated
Browse files Browse the repository at this point in the history
First argument must be set to true.
  • Loading branch information
l-vo committed Apr 18, 2021
1 parent a24fc59 commit eb0c8a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions components/validator/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ prefixed classes included in doc block comments (``/** ... */``). For example::
}

To enable the annotation loader, call the
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping`
method. It takes an optional annotation reader instance, which defaults to
``Doctrine\Common\Annotations\AnnotationReader``::
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping` method.
``addDefaultDoctrineAnnotationReader`` must also be called to use ``Doctrine\Common\Annotations\AnnotationReader``::

use Symfony\Component\Validator\Validation;

$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->enableAnnotationMapping(true)
->addDefaultDoctrineAnnotationReader()
->getValidator();

To disable the annotation loader after it was enabled, call
Expand All @@ -134,7 +134,8 @@ multiple mappings::
use Symfony\Component\Validator\Validation;

$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->enableAnnotationMapping(true)
->addDefaultDoctrineAnnotationReader()
->addMethodMapping('loadValidatorMetadata')
->addXmlMapping('validator/validation.xml')
->getValidator();
Expand Down
3 changes: 2 additions & 1 deletion form/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ allows you to return a list of extensions to register::

// or if you also need to read constraints from annotations
$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->enableAnnotationMapping(true)
->addDefaultDoctrineAnnotationReader()
->getValidator();

return [
Expand Down

0 comments on commit eb0c8a4

Please sign in to comment.