5
5
*/
6
6
declare (strict_types=1 );
7
7
8
- namespace Magento \DirectoryGraphQl \Model \Cache \Tag \Strategy ;
8
+ namespace Magento \DirectoryGraphQl \Model \Cache \Tag \Strategy \ Config ;
9
9
10
10
use Magento \DirectoryGraphQl \Model \Resolver \Country \Identity ;
11
- use Magento \Framework \App \Cache \Tag \StrategyInterface ;
12
11
use Magento \Framework \App \Config \ValueInterface ;
13
12
use Magento \Store \Model \ScopeInterface ;
14
13
use Magento \Store \Model \StoreManagerInterface ;
14
+ use Magento \Store \Model \Config \Cache \Tag \Strategy \TagGeneratorInterface ;
15
15
16
16
/**
17
- * Produce cache tags for country config.
17
+ * Generator that generates cache tags for country configuration
18
18
*/
19
- class CountryConfig implements StrategyInterface
19
+ class CountryTagGenerator implements TagGeneratorInterface
20
20
{
21
21
/**
22
22
* @var string[]
@@ -43,31 +43,23 @@ public function __construct(
43
43
/**
44
44
* @inheritdoc
45
45
*/
46
- public function getTags ( $ object ): array
46
+ public function generateTags ( ValueInterface $ config ): array
47
47
{
48
- if (!is_object ($ object )) {
49
- throw new \InvalidArgumentException ('Provided argument is not an object ' );
50
- }
51
-
52
- if ($ object instanceof ValueInterface
53
- && in_array ($ object ->getPath (), $ this ->countryConfigPaths )
54
- && $ object ->isValueChanged ()
55
- ) {
56
- if ($ object ->getScope () == ScopeInterface::SCOPE_WEBSITES ) {
57
- $ website = $ this ->storeManager ->getWebsite ($ object ->getScopeId ());
48
+ if (in_array ($ config ->getPath (), $ this ->countryConfigPaths )) {
49
+ if ($ config ->getScope () == ScopeInterface::SCOPE_WEBSITES ) {
50
+ $ website = $ this ->storeManager ->getWebsite ($ config ->getScopeId ());
58
51
$ storeIds = $ website ->getStoreIds ();
59
- } elseif ($ object ->getScope () == ScopeInterface::SCOPE_STORES ) {
60
- $ storeIds = [$ object ->getScopeId ()];
52
+ } elseif ($ config ->getScope () == ScopeInterface::SCOPE_STORES ) {
53
+ $ storeIds = [$ config ->getScopeId ()];
61
54
} else {
62
55
$ storeIds = array_keys ($ this ->storeManager ->getStores ());
63
56
}
64
- $ ids = [];
57
+ $ tags = [];
65
58
foreach ($ storeIds as $ storeId ) {
66
- $ ids [] = sprintf ('%s_%s ' , Identity::CACHE_TAG , $ storeId );
59
+ $ tags [] = sprintf ('%s_%s ' , Identity::CACHE_TAG , $ storeId );
67
60
}
68
- return $ ids ;
61
+ return $ tags ;
69
62
}
70
-
71
63
return [];
72
64
}
73
65
}
0 commit comments