55 */
66declare (strict_types=1 );
77
8- namespace Magento \DirectoryGraphQl \Model \Cache \Tag \Strategy ;
8+ namespace Magento \DirectoryGraphQl \Model \Cache \Tag \Strategy \ Config ;
99
1010use Magento \DirectoryGraphQl \Model \Resolver \Country \Identity ;
11- use Magento \Framework \App \Cache \Tag \StrategyInterface ;
1211use Magento \Framework \App \Config \ValueInterface ;
1312use Magento \Store \Model \ScopeInterface ;
1413use Magento \Store \Model \StoreManagerInterface ;
14+ use Magento \Store \Model \Config \Cache \Tag \Strategy \TagGeneratorInterface ;
1515
1616/**
17- * Produce cache tags for country config.
17+ * Generator that generates cache tags for country configuration
1818 */
19- class CountryConfig implements StrategyInterface
19+ class CountryTagGenerator implements TagGeneratorInterface
2020{
2121 /**
2222 * @var string[]
@@ -43,31 +43,23 @@ public function __construct(
4343 /**
4444 * @inheritdoc
4545 */
46- public function getTags ( $ object ): array
46+ public function generateTags ( ValueInterface $ config ): array
4747 {
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 ());
5851 $ 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 ()];
6154 } else {
6255 $ storeIds = array_keys ($ this ->storeManager ->getStores ());
6356 }
64- $ ids = [];
57+ $ tags = [];
6558 foreach ($ storeIds as $ storeId ) {
66- $ ids [] = sprintf ('%s_%s ' , Identity::CACHE_TAG , $ storeId );
59+ $ tags [] = sprintf ('%s_%s ' , Identity::CACHE_TAG , $ storeId );
6760 }
68- return $ ids ;
61+ return $ tags ;
6962 }
70-
7163 return [];
7264 }
7365}
0 commit comments