@@ -20,19 +20,11 @@ class RenderingCacheContextPlugin
20
20
public const RENDERING_WITH_BACKEND = 'with_backend ' ;
21
21
public const RENDERING_WITHOUT_BACKEND = 'without_backend ' ;
22
22
23
- private $ configHelper ;
24
- private $ storeManager ;
25
- private $ request ;
26
-
27
23
public function __construct (
28
- ConfigHelper $ configHelper ,
29
- StoreManagerInterface $ storeManager ,
30
- Http $ request
31
- ) {
32
- $ this ->configHelper = $ configHelper ;
33
- $ this ->storeManager = $ storeManager ;
34
- $ this ->request = $ request ;
35
- }
24
+ protected ConfigHelper $ configHelper ,
25
+ protected StoreManagerInterface $ storeManager ,
26
+ protected Http $ request
27
+ ) { }
36
28
37
29
/**
38
30
* Add a rendering context to the vary string to distinguish how which versions of the category PLP should be cached
@@ -45,8 +37,7 @@ public function __construct(
45
37
* @throws NoSuchEntityException
46
38
*/
47
39
public function beforeGetVaryString (HttpContext $ subject ): array {
48
- $ storeId = $ this ->storeManager ->getStore ()->getId ();
49
- if ($ this ->request ->getControllerName () != 'category ' || !$ this ->configHelper ->replaceCategories ($ storeId )) {
40
+ if (!$ this ->applyCacheContext ()) {
50
41
return [];
51
42
}
52
43
@@ -62,4 +53,14 @@ public function beforeGetVaryString(HttpContext $subject): array {
62
53
63
54
return [];
64
55
}
56
+
57
+ /**
58
+ * @return bool
59
+ * @throws NoSuchEntityException
60
+ */
61
+ protected function applyCacheContext (): bool
62
+ {
63
+ $ storeId = $ this ->storeManager ->getStore ()->getId ();
64
+ return $ this ->request ->getControllerName () == 'category ' && $ this ->configHelper ->replaceCategories ($ storeId );
65
+ }
65
66
}
0 commit comments