File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
Resources/doc/reference/configuration Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ Changelog
66
77### Added
88
9+ * Autoconfigure support for custom context providers.
10+
911* Autowiring support for the services in this bundle:
1012
1113 - fos_http_cache.cache_manager => FOS\HttpCacheBundle\CacheManager
Original file line number Diff line number Diff line change @@ -231,6 +231,13 @@ Custom providers need to:
231231* implement the ``FOS\HttpCache\UserContext\ContextProvider `` interface
232232* be tagged with ``fos_http_cache.user_context_provider ``.
233233
234+ .. versionadded :: 2.4.0
235+ Autoconfigure support has been added in version 2.4.0 and works from
236+ Symfony 3.3 and above. If autoconfigure is enabled, your custom provider
237+ will be tagged automatically, with a default priority of 0. For older
238+ versions, or if autoconfigure is disabled, or you want to override the
239+ priority, check out the section below.
240+
234241If you need context providers to run in a specific order, you can specify the
235242optional ``priority `` parameter for the tag. The higher the priority, the
236243earlier a context provider is executed. The build-in provider has a priority
Original file line number Diff line number Diff line change 1111
1212namespace FOS \HttpCacheBundle ;
1313
14+ use FOS \HttpCache \UserContext \ContextProvider ;
1415use FOS \HttpCacheBundle \DependencyInjection \Compiler \HashGeneratorPass ;
1516use FOS \HttpCacheBundle \DependencyInjection \Compiler \LoggerPass ;
1617use FOS \HttpCacheBundle \DependencyInjection \Compiler \SessionListenerRemovePass ;
@@ -35,6 +36,13 @@ public function build(ContainerBuilder $container)
3536 ) {
3637 $ container ->addCompilerPass (new SessionListenerRemovePass ());
3738 }
39+
40+ // Symfony 3.3 and higher
41+ if (method_exists ($ container , 'registerForAutoconfiguration ' )) {
42+ $ container
43+ ->registerForAutoconfiguration (ContextProvider::class)
44+ ->addTag ('fos_http_cache.user_context_provider ' );
45+ }
3846 }
3947
4048 public function registerCommands (Application $ application )
You can’t perform that action at this time.
0 commit comments