File tree Expand file tree Collapse file tree 19 files changed +94
-162
lines changed Expand file tree Collapse file tree 19 files changed +94
-162
lines changed Original file line number Diff line number Diff line change @@ -73,13 +73,4 @@ public function getProduct()
73
73
}
74
74
return $ this ->getData ('product ' );
75
75
}
76
-
77
- /**
78
- * Get Block Identities
79
- * @return Array
80
- */
81
- public function getIdentities ()
82
- {
83
- return [\Magento \Catalog \Model \Product::CACHE_TAG . '_relatedposts_ ' .$ this ->getProduct ()->getId () ];
84
- }
85
76
}
Original file line number Diff line number Diff line change 9
9
namespace Magefan \Blog \Block \Category ;
10
10
11
11
use Magefan \Blog \Model \Config \Source \CategoryDisplayMode ;
12
+ use Magento \Framework \DataObject \IdentityInterface ;
12
13
13
14
/**
14
15
* Blog category posts list
15
16
*/
16
- class PostList extends \Magefan \Blog \Block \Post \PostList
17
+ class PostList extends \Magefan \Blog \Block \Post \PostList implements IdentityInterface
17
18
{
19
+
18
20
/**
19
21
* Prepare posts collection
20
22
*
Original file line number Diff line number Diff line change 17
17
*/
18
18
class View extends \Magefan \Blog \Block \Post \PostList
19
19
{
20
+
20
21
/**
21
22
* Prepare posts collection
22
23
*
Original file line number Diff line number Diff line change 13
13
/**
14
14
* Abstract blog post list block
15
15
*/
16
- abstract class AbstractList extends \Magento \Framework \View \Element \Template
16
+ abstract class AbstractList extends \Magento \Framework \View \Element \Template implements \ Magento \ Framework \ DataObject \IdentityInterface
17
17
{
18
18
/**
19
19
* @var \Magento\Cms\Model\Template\FilterProvider
@@ -117,4 +117,18 @@ protected function _toHtml()
117
117
118
118
return parent ::_toHtml ();
119
119
}
120
+
121
+ /**
122
+ * Retrieve identities
123
+ *
124
+ * @return array
125
+ */
126
+ public function getIdentities () {
127
+ $ identities = [];
128
+ foreach ($ this ->getPostCollection () as $ item ) {
129
+ $ identities = array_merge ($ identities , $ item ->getIdentities ());
130
+ }
131
+
132
+ return array_unique ($ identities );
133
+ }
120
134
}
Original file line number Diff line number Diff line change @@ -16,37 +16,13 @@ class View extends AbstractPost implements \Magento\Framework\DataObject\Identit
16
16
{
17
17
18
18
/**
19
- * Return identifiers for produced content
19
+ * Retrieve identities
20
20
*
21
- * @return array
21
+ * @return string
22
22
*/
23
23
public function getIdentities ()
24
24
{
25
- $ i = $ this ->getPost ()->getIdentities ();
26
- var_dump ($ i );
27
- echo self ::printDebugBacktrace ($ this ->getNameInLayout ());
28
-
29
- return $ i ;
30
- }
31
-
32
- public static function printDebugBacktrace ($ title = 'Debug Backtrace: ' ) {
33
- $ output = "" ;
34
- $ output .= "<hr /><div> " . $ title . '<br /><table border="1" cellpadding="2" cellspacing="2"> ' ;
35
-
36
- $ stacks = debug_backtrace ();
37
-
38
- $ output .= "<thead><tr><th><strong>File</strong></th><th><strong>Line</strong></th><th><strong>Function</strong></th> " .
39
- "</tr></thead> " ;
40
- foreach ($ stacks as $ _stack )
41
- {
42
- if (!isset ($ _stack ['file ' ])) $ _stack ['file ' ] = '[PHP Kernel] ' ;
43
- if (!isset ($ _stack ['line ' ])) $ _stack ['line ' ] = '' ;
44
-
45
- $ output .= "<tr><td> {$ _stack ["file " ]}</td><td> {$ _stack ["line " ]}</td> " .
46
- "<td> {$ _stack ["function " ]}</td></tr> " ;
47
- }
48
- $ output .= "</table></div><hr /></p> " ;
49
- return $ output ;
25
+ return $ this ->getPost ()->getIdentities ();
50
26
}
51
27
52
28
/**
Original file line number Diff line number Diff line change 16
16
* @method string getComment()
17
17
* @method $this setComment(\Magefan\Blog\Model\Comment $comment)
18
18
*/
19
- class Comment extends \Magento \Framework \View \Element \Template
19
+ class Comment extends \Magento \Framework \View \Element \Template implements \ Magento \ Framework \ DataObject \IdentityInterface
20
20
{
21
21
/**
22
22
* @var array
@@ -29,6 +29,17 @@ class Comment extends \Magento\Framework\View\Element\Template
29
29
*/
30
30
protected $ _template = 'Magefan_Blog::post/view/comments/magefan/comment.phtml ' ;
31
31
32
+
33
+ /**
34
+ * Retrieve identities
35
+ *
36
+ * @return string
37
+ */
38
+ public function getIdentities ()
39
+ {
40
+ return $ this ->getComment ()->getIdentities ();
41
+ }
42
+
32
43
/**
33
44
* Retrieve sub-comments collection or empty array
34
45
*
Original file line number Diff line number Diff line change @@ -62,13 +62,4 @@ public function getPost()
62
62
}
63
63
return $ this ->getData ('post ' );
64
64
}
65
-
66
- /**
67
- * Get Block Identities
68
- * @return Array
69
- */
70
- public function getIdentities ()
71
- {
72
- return [\Magento \Cms \Model \Page::CACHE_TAG . '_relatedposts_ ' .$ this ->getPost ()->getId () ];
73
- }
74
65
}
Original file line number Diff line number Diff line change @@ -125,14 +125,4 @@ public function getPost()
125
125
}
126
126
return $ this ->getData ('post ' );
127
127
}
128
-
129
- /**
130
- * Get Block Identities
131
- * @return Array
132
- */
133
- public function getIdentities ()
134
- {
135
- $ post = $ this ->getPost ();
136
- return $ post ? [ \Magento \Cms \Model \Page::CACHE_TAG . '_relatedproducts_ ' . $ post ->getId () ] : [];
137
- }
138
128
}
Original file line number Diff line number Diff line change @@ -42,12 +42,4 @@ public function getDescription()
42
42
return $ this ->_scopeConfig ->getValue ('mfblog/rss_feed/description ' , ScopeInterface::SCOPE_STORE );
43
43
}
44
44
45
- /**
46
- * Retrieve block identities
47
- * @return array
48
- */
49
- public function getIdentities ()
50
- {
51
- return [\Magento \Cms \Model \Page::CACHE_TAG . '_blog_rss_feed ' ];
52
- }
53
45
}
Original file line number Diff line number Diff line change @@ -91,13 +91,4 @@ public function getTimeUrl($time)
91
91
\Magefan \Blog \Model \Url::CONTROLLER_ARCHIVE
92
92
);
93
93
}
94
-
95
- /**
96
- * Retrieve blog identities
97
- * @return array
98
- */
99
- public function getIdentities ()
100
- {
101
- return [\Magento \Cms \Model \Block::CACHE_TAG . '_blog_archive_widget ' ];
102
- }
103
94
}
Original file line number Diff line number Diff line change 13
13
/**
14
14
* Blog sidebar categories block
15
15
*/
16
- class Categories extends \Magento \Framework \View \Element \Template
16
+ class Categories extends \Magento \Framework \View \Element \Template implements \ Magento \ Framework \ DataObject \IdentityInterface
17
17
{
18
18
use Widget;
19
19
@@ -85,17 +85,6 @@ public function showPostsCount()
85
85
return $ this ->getData ($ key );
86
86
}
87
87
88
-
89
- /**
90
- * Retrieve block identities
91
- * @return array
92
- */
93
- public function getIdentities ()
94
- {
95
- return [\Magento \Cms \Model \Block::CACHE_TAG . '_blog_categories_widget ' ];
96
- }
97
-
98
-
99
88
/**
100
89
* Retrieve categories maximum depth
101
90
* @return int
@@ -109,4 +98,18 @@ public function maxDepth()
109
98
110
99
return (int )$ maxDepth ;
111
100
}
101
+
102
+ /**
103
+ * Retrieve block identities
104
+ *
105
+ * @return array
106
+ */
107
+ public function getIdentities () {
108
+ $ identities = [];
109
+ foreach ($ this ->getGroupedChilds () as $ item ) {
110
+ $ identities = array_merge ($ identities , $ item ->getIdentities ());
111
+ }
112
+
113
+ return array_unique ($ identities );
114
+ }
112
115
}
Original file line number Diff line number Diff line change @@ -45,12 +45,4 @@ protected function getPostIdsConfigValue()
45
45
);
46
46
}
47
47
48
- /**
49
- * Retrieve block identities
50
- * @return array
51
- */
52
- public function getIdentities ()
53
- {
54
- return [\Magento \Cms \Model \Block::CACHE_TAG . '_blog_featured_posts_widget_ ' . $ this ->getPostIdsConfigValue () ];
55
- }
56
48
}
Original file line number Diff line number Diff line change @@ -45,12 +45,4 @@ protected function _preparePostCollection()
45
45
$ this ->_postCollection ->addRecentFilter ();
46
46
}
47
47
48
- /**
49
- * Retrieve block identities
50
- * @return array
51
- */
52
- public function getIdentities ()
53
- {
54
- return [\Magento \Cms \Model \Block::CACHE_TAG . '_blog_recent_posts_widget ' ];
55
- }
56
48
}
Original file line number Diff line number Diff line change @@ -26,12 +26,4 @@ class Rss extends \Magento\Framework\View\Element\Template
26
26
*/
27
27
protected $ _months ;
28
28
29
- /**
30
- * Retrieve blog identities
31
- * @return array
32
- */
33
- public function getIdentities ()
34
- {
35
- return [\Magento \Cms \Model \Block::CACHE_TAG . '_blog_rss_widget ' ];
36
- }
37
29
}
Original file line number Diff line number Diff line change @@ -125,12 +125,4 @@ public function getTagClass($tag)
125
125
return 'largest ' ;
126
126
}
127
127
128
- /**
129
- * Retrieve block identities
130
- * @return array
131
- */
132
- public function getIdentities ()
133
- {
134
- return [\Magento \Cms \Model \Block::CACHE_TAG . '_blog_tag_claud_widget ' ];
135
- }
136
128
}
Original file line number Diff line number Diff line change 14
14
15
15
class Featured extends \Magefan \Blog \Block \Sidebar \Featured implements \Magento \Widget \Block \BlockInterface
16
16
{
17
+
17
18
/**
18
19
* Set blog template
19
20
*
Original file line number Diff line number Diff line change 9
9
namespace Magefan \Blog \Model ;
10
10
11
11
use Magefan \Blog \Model \Url ;
12
+ use Magento \Framework \DataObject \IdentityInterface ;
12
13
13
14
/**
14
15
* Category model
26
27
* @method string getIdentifier()
27
28
* @method $this setIdentifier(string $value)
28
29
*/
29
- class Category extends \Magento \Framework \Model \AbstractModel
30
+ class Category extends \Magento \Framework \Model \AbstractModel implements IdentityInterface
30
31
{
32
+
33
+ /**
34
+ * blog cache category
35
+ */
36
+ const CACHE_TAG = 'mfb_c ' ;
37
+
31
38
/**
32
39
* Category's Statuses
33
40
*/
@@ -105,6 +112,16 @@ protected function _construct()
105
112
$ this ->controllerName = URL ::CONTROLLER_CATEGORY ;
106
113
}
107
114
115
+ /**
116
+ * Retrieve identities
117
+ *
118
+ * @return array
119
+ */
120
+ public function getIdentities ()
121
+ {
122
+ return [self ::CACHE_TAG . '_ ' . $ this ->getId ()];
123
+ }
124
+
108
125
/**
109
126
* Load object data
110
127
*
Original file line number Diff line number Diff line change 38
38
* @method string getUpdateTime()
39
39
* @method $this setUpdateTime(string $value)
40
40
*/
41
- class Comment extends AbstractModel
41
+ class Comment extends AbstractModel implements \ Magento \ Framework \ DataObject \IdentityInterface
42
42
{
43
43
/**
44
44
* @var \Magefan\Blog\Model\AuthorFactory
@@ -70,6 +70,11 @@ class Comment extends AbstractModel
70
70
*/
71
71
protected $ comments ;
72
72
73
+ /**
74
+ * blog cache comment
75
+ */
76
+ const CACHE_TAG = 'mfb_co ' ;
77
+
73
78
/**
74
79
* Initialize dependencies.
75
80
* @param \Magento\Framework\Model\Context $context
@@ -101,6 +106,17 @@ public function __construct(
101
106
$ this ->commentCollectionFactory = $ commentCollectionFactory ;
102
107
}
103
108
109
+ /**
110
+ * Retrieve identities
111
+ *
112
+ * @return array
113
+ */
114
+ public function getIdentities ()
115
+ {
116
+ return [self ::CACHE_TAG . '_ ' . $ this ->getId ()];
117
+ }
118
+
119
+
104
120
/**
105
121
* Initialize resource model
106
122
*
You can’t perform that action at this time.
0 commit comments