Skip to content

Document the validator's switch to PSR-6 #12276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions components/validator/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,21 @@ can slow down your application because each file needs to be parsed, validated
and converted into a :class:`Symfony\\Component\\Validator\\Mapping\\ClassMetadata`
instance.

To solve this problem, call the :method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataCache`
To solve this problem, call the :method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMappingCache`
method of the Validator builder and pass your own caching class (which must
implement :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`)::
implement the PSR-6 interface :class:`Psr\\Cache\\CacheItemPoolInterface`)::

use Symfony\Component\Validator\Validation;

$validator = Validation::createValidatorBuilder()
// ... add loaders
->setMetadataCache(new SomeImplementCacheInterface());
->setMappingCache(new SomePsr6Cache());
->getValidator();

.. versionadded:: 4.4

Support for PSR-6 compatible mapping caches was introduced in Symfony 4.4.

.. note::

The loaders already use a singleton load mechanism. That means that the
Expand Down