Skip to content

Commit 7d4a554

Browse files
Minor reword
1 parent 9b9bb7c commit 7d4a554

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

components/validator/resources.rst

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,18 @@ Caching
148148
Using many loaders to load metadata from different places is convenient, but it
149149
can slow down your application because each file needs to be parsed, validated
150150
and converted into a :class:`Symfony\\Component\\Validator\\Mapping\\ClassMetadata`
151-
instance. To solve this problem, you can cache the ``ClassMetadata`` information.
151+
instance.
152152

153-
You can easily create cachers by creating a class which
154-
implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`.
153+
To solve this problem, call the :method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataCache`
154+
method of the Validator builder and pass your own caching class (which must
155+
implement :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface`)::
156+
157+
use Symfony\Component\Validator\Validation;
158+
159+
$validator = Validation::createValidatorBuilder()
160+
// ... add loaders
161+
->setMetadataCache(new SomeImplementCacheInterface());
162+
->getValidator();
155163

156164
.. note::
157165

@@ -161,17 +169,6 @@ implements :class:`Symfony\\Component\\Validator\\Mapping\\Cache\\CacheInterface
161169
the Validator still needs to merge all metadata of one class from every
162170
loader when it is requested.
163171

164-
Enable the cache calling the
165-
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::setMetadataCache`
166-
method of the Validator builder::
167-
168-
use Symfony\Component\Validator\Validation;
169-
170-
$validator = Validation::createValidatorBuilder()
171-
// ... add loaders
172-
->setMetadataCache(new SomeImplementCacheInterface());
173-
->getValidator();
174-
175172
Using a Custom MetadataFactory
176173
------------------------------
177174

0 commit comments

Comments
 (0)