Skip to content

Commit e4d0479

Browse files
committed
clean cache by save
1 parent b71603f commit e4d0479

File tree

19 files changed

+94
-162
lines changed

19 files changed

+94
-162
lines changed

Block/Catalog/Product/RelatedPosts.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,4 @@ public function getProduct()
7373
}
7474
return $this->getData('product');
7575
}
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-
}
8576
}

Block/Category/PostList.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
namespace Magefan\Blog\Block\Category;
1010

1111
use Magefan\Blog\Model\Config\Source\CategoryDisplayMode;
12+
use Magento\Framework\DataObject\IdentityInterface;
1213

1314
/**
1415
* Blog category posts list
1516
*/
16-
class PostList extends \Magefan\Blog\Block\Post\PostList
17+
class PostList extends \Magefan\Blog\Block\Post\PostList implements IdentityInterface
1718
{
19+
1820
/**
1921
* Prepare posts collection
2022
*

Block/Category/View.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
class View extends \Magefan\Blog\Block\Post\PostList
1919
{
20+
2021
/**
2122
* Prepare posts collection
2223
*

Block/Post/PostList/AbstractList.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Abstract blog post list block
1515
*/
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
1717
{
1818
/**
1919
* @var \Magento\Cms\Model\Template\FilterProvider
@@ -117,4 +117,18 @@ protected function _toHtml()
117117

118118
return parent::_toHtml();
119119
}
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+
}
120134
}

Block/Post/View.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,13 @@ class View extends AbstractPost implements \Magento\Framework\DataObject\Identit
1616
{
1717

1818
/**
19-
* Return identifiers for produced content
19+
* Retrieve identities
2020
*
21-
* @return array
21+
* @return string
2222
*/
2323
public function getIdentities()
2424
{
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();
5026
}
5127

5228
/**

Block/Post/View/Comments/Magefan/Comment.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @method string getComment()
1717
* @method $this setComment(\Magefan\Blog\Model\Comment $comment)
1818
*/
19-
class Comment extends \Magento\Framework\View\Element\Template
19+
class Comment extends \Magento\Framework\View\Element\Template implements \Magento\Framework\DataObject\IdentityInterface
2020
{
2121
/**
2222
* @var array
@@ -29,6 +29,17 @@ class Comment extends \Magento\Framework\View\Element\Template
2929
*/
3030
protected $_template = 'Magefan_Blog::post/view/comments/magefan/comment.phtml';
3131

32+
33+
/**
34+
* Retrieve identities
35+
*
36+
* @return string
37+
*/
38+
public function getIdentities()
39+
{
40+
return $this->getComment()->getIdentities();
41+
}
42+
3243
/**
3344
* Retrieve sub-comments collection or empty array
3445
*

Block/Post/View/RelatedPosts.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,4 @@ public function getPost()
6262
}
6363
return $this->getData('post');
6464
}
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-
}
7465
}

Block/Post/View/RelatedProducts.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,4 @@ public function getPost()
125125
}
126126
return $this->getData('post');
127127
}
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-
}
138128
}

Block/Rss/Feed.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,4 @@ public function getDescription()
4242
return $this->_scopeConfig->getValue('mfblog/rss_feed/description', ScopeInterface::SCOPE_STORE);
4343
}
4444

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-
}
5345
}

Block/Sidebar/Archive.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,4 @@ public function getTimeUrl($time)
9191
\Magefan\Blog\Model\Url::CONTROLLER_ARCHIVE
9292
);
9393
}
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-
}
10394
}

Block/Sidebar/Categories.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Blog sidebar categories block
1515
*/
16-
class Categories extends \Magento\Framework\View\Element\Template
16+
class Categories extends \Magento\Framework\View\Element\Template implements \Magento\Framework\DataObject\IdentityInterface
1717
{
1818
use Widget;
1919

@@ -85,17 +85,6 @@ public function showPostsCount()
8585
return $this->getData($key);
8686
}
8787

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-
9988
/**
10089
* Retrieve categories maximum depth
10190
* @return int
@@ -109,4 +98,18 @@ public function maxDepth()
10998

11099
return (int)$maxDepth;
111100
}
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+
}
112115
}

Block/Sidebar/Featured.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,4 @@ protected function getPostIdsConfigValue()
4545
);
4646
}
4747

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-
}
5648
}

Block/Sidebar/Recent.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,4 @@ protected function _preparePostCollection()
4545
$this->_postCollection->addRecentFilter();
4646
}
4747

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-
}
5648
}

Block/Sidebar/Rss.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,4 @@ class Rss extends \Magento\Framework\View\Element\Template
2626
*/
2727
protected $_months;
2828

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-
}
3729
}

Block/Sidebar/TagClaud.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,4 @@ public function getTagClass($tag)
125125
return 'largest';
126126
}
127127

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-
}
136128
}

Block/Widget/Featured.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class Featured extends \Magefan\Blog\Block\Sidebar\Featured implements \Magento\Widget\Block\BlockInterface
1616
{
17+
1718
/**
1819
* Set blog template
1920
*

Model/Category.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magefan\Blog\Model;
1010

1111
use Magefan\Blog\Model\Url;
12+
use Magento\Framework\DataObject\IdentityInterface;
1213

1314
/**
1415
* Category model
@@ -26,8 +27,14 @@
2627
* @method string getIdentifier()
2728
* @method $this setIdentifier(string $value)
2829
*/
29-
class Category extends \Magento\Framework\Model\AbstractModel
30+
class Category extends \Magento\Framework\Model\AbstractModel implements IdentityInterface
3031
{
32+
33+
/**
34+
* blog cache category
35+
*/
36+
const CACHE_TAG = 'mfb_c';
37+
3138
/**
3239
* Category's Statuses
3340
*/
@@ -105,6 +112,16 @@ protected function _construct()
105112
$this->controllerName = URL::CONTROLLER_CATEGORY;
106113
}
107114

115+
/**
116+
* Retrieve identities
117+
*
118+
* @return array
119+
*/
120+
public function getIdentities()
121+
{
122+
return [self::CACHE_TAG . '_' . $this->getId()];
123+
}
124+
108125
/**
109126
* Load object data
110127
*

Model/Comment.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* @method string getUpdateTime()
3939
* @method $this setUpdateTime(string $value)
4040
*/
41-
class Comment extends AbstractModel
41+
class Comment extends AbstractModel implements \Magento\Framework\DataObject\IdentityInterface
4242
{
4343
/**
4444
* @var \Magefan\Blog\Model\AuthorFactory
@@ -70,6 +70,11 @@ class Comment extends AbstractModel
7070
*/
7171
protected $comments;
7272

73+
/**
74+
* blog cache comment
75+
*/
76+
const CACHE_TAG = 'mfb_co';
77+
7378
/**
7479
* Initialize dependencies.
7580
* @param \Magento\Framework\Model\Context $context
@@ -101,6 +106,17 @@ public function __construct(
101106
$this->commentCollectionFactory = $commentCollectionFactory;
102107
}
103108

109+
/**
110+
* Retrieve identities
111+
*
112+
* @return array
113+
*/
114+
public function getIdentities()
115+
{
116+
return [self::CACHE_TAG . '_' . $this->getId()];
117+
}
118+
119+
104120
/**
105121
* Initialize resource model
106122
*

0 commit comments

Comments
 (0)