Skip to content

Commit b8d0de5

Browse files
committed
fix cache tags
1 parent 5c4a007 commit b8d0de5

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

Model/Document.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
use Magento\Framework\Model\AbstractExtensibleModel;
1414
use Opengento\Document\Api\Data\DocumentExtensionInterface;
1515
use Opengento\Document\Api\Data\DocumentInterface;
16+
use function array_merge;
1617

1718
class Document extends AbstractExtensibleModel implements DocumentInterface, IdentityInterface
1819
{
19-
public const CACHE_TAG = 'opengento_document';
20+
public const CACHE_TAG = 'ope_d';
2021

2122
protected function _construct(): void
2223
{
@@ -28,12 +29,18 @@ protected function _construct(): void
2829
public function getIdentities(): array
2930
{
3031
return [
32+
self::CACHE_TAG,
3133
self::CACHE_TAG . '_' . $this->getId(),
3234
self::CACHE_TAG . '_' . $this->getCode(),
3335
DocumentType::CACHE_TAG . '_' . $this->getTypeId(),
3436
];
3537
}
3638

39+
public function getCacheTags(): array
40+
{
41+
return $this->getIdentities() ?: parent::getCacheTags();
42+
}
43+
3744
public function getId(): ?int
3845
{
3946
return parent::getId() ? (int) parent::getId() : null;

Model/DocumentType.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
use Magento\Framework\Model\AbstractExtensibleModel;
1414
use Opengento\Document\Api\Data\DocumentTypeExtensionInterface;
1515
use Opengento\Document\Api\Data\DocumentTypeInterface;
16+
use function array_merge;
1617
use function explode;
1718

1819
class DocumentType extends AbstractExtensibleModel implements DocumentTypeInterface, IdentityInterface
1920
{
20-
public const CACHE_TAG = 'opengento_document_type';
21+
public const CACHE_TAG = 'ope_dt';
2122

2223
protected function _construct(): void
2324
{
@@ -28,7 +29,12 @@ protected function _construct(): void
2829

2930
public function getIdentities(): array
3031
{
31-
return [self::CACHE_TAG . '_' . $this->getId(), self::CACHE_TAG . '_' . $this->getCode()];
32+
return [self::CACHE_TAG, self::CACHE_TAG . '_' . $this->getId(), self::CACHE_TAG . '_' . $this->getCode()];
33+
}
34+
35+
public function getCacheTags(): array
36+
{
37+
return $this->getIdentities() ?: parent::getCacheTags();
3238
}
3339

3440
public function getId(): ?int

etc/di.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,6 @@
146146
<argument name="fetchStrategy" xsi:type="object">Opengento\Document\Model\ResourceModel\Document\Collection\FetchStrategy</argument>
147147
</arguments>
148148
</type>
149-
<virtualType name="Opengento\Document\Model\Cache\Document" type="Opengento\Document\Model\Cache\Cache">
150-
<arguments>
151-
<argument name="cacheList" xsi:type="array">
152-
<item name="block_html" xsi:type="const">Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER</item>
153-
<item name="collections" xsi:type="const">Magento\Framework\App\Cache\Type\Collection::TYPE_IDENTIFIER</item>
154-
</argument>
155-
<argument name="tags" xsi:type="array">
156-
<item name="document" xsi:type="const">Opengento\Document\Model\Document::CACHE_TAG</item>
157-
</argument>
158-
</arguments>
159-
</virtualType>
160149
<!-- Global Settings -->
161150
<preference for="Opengento\Document\Model\Document\Operation\CreateFromFileInterface" type="Opengento\Document\Model\Document\Operation\CreateFromFile"/>
162151
<type name="Opengento\Document\Model\Document\ProcessorFactory">

0 commit comments

Comments
 (0)