@@ -56,36 +56,40 @@ public function __construct(
56
56
}
57
57
58
58
/**
59
- * Clean cache on save object
59
+ * Clean cache when object is saved
60
60
*
61
61
* @param AbstractResource $subject
62
- * @param \Closure $proceed
62
+ * @param AbstractResource $result
63
63
* @param AbstractModel $object
64
64
* @return AbstractResource
65
65
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
66
66
*/
67
- public function aroundSave (AbstractResource $ subject , \Closure $ proceed , AbstractModel $ object ): AbstractResource
68
- {
69
- $ result = $ proceed ($ object );
67
+ public function afterSave (
68
+ AbstractResource $ subject ,
69
+ AbstractResource $ result ,
70
+ AbstractModel $ object
71
+ ): AbstractResource {
70
72
$ tags = $ this ->tagResolver ->getTags ($ object );
71
73
$ this ->cleanCacheByTags ($ tags );
72
74
73
75
return $ result ;
74
76
}
75
77
76
78
/**
77
- * Clean cache on delete object
79
+ * Clean cache when object is deleted
78
80
*
79
81
* @param AbstractResource $subject
80
- * @param \Closure $proceed
82
+ * @param AbstractResource $result
81
83
* @param AbstractModel $object
82
84
* @return AbstractResource
83
85
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
84
86
*/
85
- public function aroundDelete (AbstractResource $ subject , \Closure $ proceed , AbstractModel $ object ): AbstractResource
86
- {
87
+ public function afterDelete (
88
+ AbstractResource $ subject ,
89
+ AbstractResource $ result ,
90
+ AbstractModel $ object
91
+ ): AbstractResource {
87
92
$ tags = $ this ->tagResolver ->getTags ($ object );
88
- $ result = $ proceed ($ object );
89
93
$ this ->cleanCacheByTags ($ tags );
90
94
91
95
return $ result ;
@@ -102,11 +106,12 @@ private function cleanCacheByTags(array $tags): void
102
106
if (!$ tags ) {
103
107
return ;
104
108
}
109
+ $ uniqueTags = null ;
105
110
foreach ($ this ->cacheList as $ cacheType ) {
106
111
if ($ this ->cacheState ->isEnabled ($ cacheType )) {
107
112
$ this ->cachePool ->get ($ cacheType )->clean (
108
113
\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG ,
109
- \array_unique ($ tags )
114
+ $ uniqueTags = $ uniqueTags ?? \array_unique ($ tags )
110
115
);
111
116
}
112
117
}
0 commit comments