Commit 85bff8cb authored by Fabien Potencier's avatar Fabien Potencier

minor #1482 Update documentation to add cache explaination (jlHertel)

This PR was merged into the 2.1.x-dev branch.

Discussion
----------

Update documentation to add cache explaination

This updates the documentation explaining how to setup any cache that implements the Doctrine interface. As the Symfony documentation don't clearly shows how to do this, I intend to add it here.

Commits
-------

2e0f7d38 Update documentation to add cache explaination
parents 6260671f 2e0f7d38
...@@ -71,3 +71,16 @@ The ``SerializerServiceProvider`` provider provides a ``serializer`` service:: ...@@ -71,3 +71,16 @@ The ``SerializerServiceProvider`` provider provides a ``serializer`` service::
)); ));
})->assert("_format", "xml|json") })->assert("_format", "xml|json")
->assert("id", "\d+"); ->assert("id", "\d+");
Use a Cache
-----
To use a cache you can register it in the specified encoder needed. All you need to do is have a class implementing ``Doctrine\Common\Cache\Cache``::
$app->register(new Silex\Provider\SerializerServiceProvider());
$app['serializer.normalizers'] = function () use ($app) {
return [new \Symfony\Component\Serializer\Normalizer\CustomNormalizer(),
new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()), $app['my_custom_cache']))
];
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment