File tree Expand file tree Collapse file tree 3 files changed +58
-16
lines changed
Model/Cache/Query/Resolver Expand file tree Collapse file tree 3 files changed +58
-16
lines changed Original file line number Diff line number Diff line change 6
6
*/
7
7
-->
8
8
<config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:ObjectManager/etc/config.xsd" >
9
- <type name =" Magento\GraphQlCache\Observer\InvalidateGraphQlResolverCacheObserver " >
9
+ <type name =" Magento\GraphQlCache\Model\Cache\Query\Resolver\TagResolver " >
10
10
<arguments >
11
11
<argument name =" invalidatableObjectTypes" xsi : type =" array" >
12
12
<item name =" Magento\Cms\Api\Data\PageInterface" xsi : type =" string" >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \GraphQlCache \Model \Cache \Query \Resolver ;
9
+
10
+ use Magento \Framework \App \Cache \Tag \Resolver ;
11
+ use Magento \Framework \App \Cache \Tag \Strategy \Factory as StrategyFactory ;
12
+
13
+ class TagResolver extends Resolver
14
+ {
15
+ /**
16
+ * @var array
17
+ */
18
+ private $ invalidatableObjectTypes ;
19
+
20
+ /**
21
+ * GraphQL Resolver cache-specific tag resolver for the purpose of invalidation
22
+ *
23
+ * @param StrategyFactory $factory
24
+ * @param array $invalidatableObjectTypes
25
+ */
26
+ public function __construct (
27
+ StrategyFactory $ factory ,
28
+ array $ invalidatableObjectTypes = []
29
+ ) {
30
+ $ this ->invalidatableObjectTypes = $ invalidatableObjectTypes ;
31
+
32
+ parent ::__construct ($ factory );
33
+ }
34
+
35
+ /**
36
+ * @inheritdoc
37
+ */
38
+ public function getTags ($ object )
39
+ {
40
+ $ isInvalidatable = false ;
41
+
42
+ foreach ($ this ->invalidatableObjectTypes as $ invalidatableObjectType ) {
43
+ $ isInvalidatable = $ object instanceof $ invalidatableObjectType ;
44
+
45
+ if ($ isInvalidatable ) {
46
+ break ;
47
+ }
48
+ }
49
+
50
+ if (!$ isInvalidatable ) {
51
+ return [];
52
+ }
53
+
54
+ return parent ::getTags ($ object );
55
+ }
56
+ }
Original file line number Diff line number Diff line change 8
8
namespace Magento \GraphQlCache \Observer ;
9
9
10
10
use Magento \Framework \App \Cache \StateInterface as CacheState ;
11
- use Magento \Framework \App \Cache \Tag \Resolver as TagResolver ;
12
11
use Magento \Framework \Event \ObserverInterface ;
13
12
use Magento \Framework \Event \Observer ;
13
+ use Magento \GraphQlCache \Model \Cache \Query \Resolver \TagResolver as TagResolver ;
14
14
use Magento \GraphQlCache \Model \Cache \Query \Resolver \Result \Type as GraphQlResolverCache ;
15
15
16
16
class InvalidateGraphQlResolverCacheObserver implements ObserverInterface
@@ -72,20 +72,6 @@ public function execute(Observer $observer)
72
72
return ;
73
73
}
74
74
75
- $ isInvalidatable = false ;
76
-
77
- foreach ($ this ->invalidatableObjectTypes as $ invalidatableObjectType ) {
78
- $ isInvalidatable = $ object instanceof $ invalidatableObjectType ;
79
-
80
- if ($ isInvalidatable ) {
81
- break ;
82
- }
83
- }
84
-
85
- if (!$ isInvalidatable ) {
86
- return ;
87
- }
88
-
89
75
$ tags = $ this ->tagResolver ->getTags ($ object );
90
76
91
77
if (!empty ($ tags )) {
You can’t perform that action at this time.
0 commit comments