18
18
19
19
namespace Magento \Cms \Observer ;
20
20
21
- use Magento \Catalog \Model \Product ;
22
21
use Magento \Cms \Model \Page ;
23
22
use Magento \Framework \App \Cache \Type \Layout as LayoutCache ;
24
23
use Magento \Framework \App \Cache \StateInterface as CacheState ;
25
24
use Magento \Framework \App \Cache \Tag \Resolver ;
26
25
use Magento \Framework \Event \Observer ;
27
26
use Magento \Framework \Event \ObserverInterface ;
28
- use Magento \Widget \Model \Widget \ Instance ;
27
+ use Magento \Framework \Model \AbstractModel ;
29
28
30
29
/**
31
30
* Invalidates layout cache.
@@ -81,7 +80,7 @@ public function execute(Observer $observer)
81
80
return ;
82
81
}
83
82
84
- if (!$ object ->dataHasChangedFor (Page::PAGE_LAYOUT )) {
83
+ if (!$ object instanceof Page || ! $ object ->dataHasChangedFor (Page::PAGE_LAYOUT )) {
85
84
return ;
86
85
}
87
86
@@ -95,25 +94,19 @@ public function execute(Observer $observer)
95
94
96
95
/**
97
96
* Get additional tags
97
+ *
98
+ * @param AbstractModel $object
99
+ * @return string
98
100
*/
99
- public function getAdditionalTags ($ object ): string
101
+ public function getAdditionalTags (AbstractModel $ object ): string
100
102
{
101
103
$ tag = '' ;
102
104
if ($ object instanceof Page) {
103
105
$ tag = sprintf (
104
- '%s_%s ' ,
105
- 'CMS_PAGE_VIEW_ID ' ,
106
- str_replace ('- ' , '_ ' , strtoupper ($ object ->getIdentifier ()))
107
- );
108
- } elseif ($ object instanceof Product) {
109
- $ tag = sprintf (
110
- '%s ' ,
111
- str_replace (
112
- '{{ID}} ' ,
113
- (string ) $ object ->getId (),
114
- Instance::SINGLE_PRODUCT_LAYOUT_HANDLE
115
- ),
116
- );
106
+ '%s_%s ' ,
107
+ 'CMS_PAGE_VIEW_ID ' ,
108
+ str_replace ('- ' , '_ ' , strtoupper ($ object ->getIdentifier ()))
109
+ );
117
110
}
118
111
return $ tag ;
119
112
}
0 commit comments