2323use Symfony \Component \DependencyInjection \ChildDefinition ;
2424use Symfony \Component \DependencyInjection \ContainerBuilder ;
2525use Symfony \Component \DependencyInjection \Definition ;
26- use Symfony \Component \DependencyInjection \DefinitionDecorator ;
2726use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
2827use Symfony \Component \DependencyInjection \Reference ;
2928use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
30- use Symfony \Component \HttpKernel \Kernel ;
3129use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
3230
3331/**
@@ -202,7 +200,7 @@ private function parseRuleMatcher(ContainerBuilder $container, array $match)
202200 }
203201
204202 $ container
205- ->setDefinition ($ id , $ this -> createChildDefinition ('fos_http_cache.rule_matcher ' ))
203+ ->setDefinition ($ id , new ChildDefinition ('fos_http_cache.rule_matcher ' ))
206204 ->replaceArgument (0 , $ requestMatcher )
207205 ->replaceArgument (1 , $ responseMatcher )
208206 ;
@@ -231,7 +229,7 @@ private function parseRequestMatcher(ContainerBuilder $container, array $match)
231229
232230 if (!$ container ->hasDefinition ($ id )) {
233231 $ container
234- ->setDefinition ($ id , $ this -> createChildDefinition ('fos_http_cache.request_matcher ' ))
232+ ->setDefinition ($ id , new ChildDefinition ('fos_http_cache.request_matcher ' ))
235233 ->setArguments ($ arguments )
236234 ;
237235
@@ -254,15 +252,15 @@ private function parseResponseMatcher(ContainerBuilder $container, array $config
254252 $ id = 'fos_http_cache.cache_control.expression. ' .md5 (serialize ($ config ['additional_response_status ' ]));
255253 if (!$ container ->hasDefinition ($ id )) {
256254 $ container
257- ->setDefinition ($ id , $ this -> createChildDefinition ('fos_http_cache.response_matcher.cache_control.cacheable_response ' ))
255+ ->setDefinition ($ id , new ChildDefinition ('fos_http_cache.response_matcher.cache_control.cacheable_response ' ))
258256 ->setArguments ([$ config ['additional_response_status ' ]])
259257 ;
260258 }
261259 } elseif (!empty ($ config ['match_response ' ])) {
262260 $ id = 'fos_http_cache.cache_control.match_response. ' .md5 ($ config ['match_response ' ]);
263261 if (!$ container ->hasDefinition ($ id )) {
264262 $ container
265- ->setDefinition ($ id , $ this -> createChildDefinition ('fos_http_cache.response_matcher.cache_control.expression ' ))
263+ ->setDefinition ($ id , new ChildDefinition ('fos_http_cache.response_matcher.cache_control.expression ' ))
266264 ->replaceArgument (0 , $ config ['match_response ' ])
267265 ;
268266 }
@@ -318,19 +316,6 @@ private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loa
318316 ->addTag (HashGeneratorPass::TAG_NAME )
319317 ->setAbstract (false );
320318 }
321-
322- // Only decorate default SessionListener for Symfony 3.4 - 4.0
323- // For Symfony 4.1+, the UserContextListener sets the header that tells
324- // the SessionListener to leave the cache-control header unchanged.
325- if (version_compare (Kernel::VERSION , '3.4 ' , '>= ' )
326- && version_compare (Kernel::VERSION , '4.1 ' , '< ' )
327- ) {
328- $ container ->getDefinition ('fos_http_cache.user_context.session_listener ' )
329- ->setArgument (1 , strtolower ($ config ['user_hash_header ' ]))
330- ->setArgument (2 , $ completeUserIdentifierHeaders );
331- } else {
332- $ container ->removeDefinition ('fos_http_cache.user_context.session_listener ' );
333- }
334319 }
335320
336321 private function loadProxyClient (ContainerBuilder $ container , XmlFileLoader $ loader , array $ config )
@@ -622,20 +607,4 @@ private function getDefaultProxyClient(array $config)
622607
623608 throw new InvalidConfigurationException ('No proxy client configured ' );
624609 }
625-
626- /**
627- * Build the child definition with fallback for Symfony versions < 3.3.
628- *
629- * @param string $id Id of the service to extend
630- *
631- * @return ChildDefinition|DefinitionDecorator
632- */
633- private function createChildDefinition ($ id )
634- {
635- if (class_exists (ChildDefinition::class)) {
636- return new ChildDefinition ($ id );
637- }
638-
639- return new DefinitionDecorator ($ id );
640- }
641610}
0 commit comments