Skip to content

Commit 57755d2

Browse files
committed
B2B-2259: customAttributeMetadata GraphQl query has no cache identity
1 parent 92adead commit 57755d2

File tree

1 file changed

+12
-66
lines changed

1 file changed

+12
-66
lines changed

app/code/Magento/EavGraphQl/Plugin/Eav/AttributePlugin.php

Lines changed: 12 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,31 @@
88
namespace Magento\EavGraphQl\Plugin\Eav;
99

1010
use Magento\Eav\Model\Entity\Attribute;
11-
use Magento\Framework\DataObject\IdentityInterface;
12-
use Magento\Framework\Event\ManagerInterface;
1311

1412
/**
1513
* EAV plugin runs page cache clean and provides proper EAV identities.
1614
*/
17-
class AttributePlugin implements IdentityInterface
15+
class AttributePlugin
1816
{
19-
/**
20-
* Application Event Dispatcher
21-
*
22-
* @var ManagerInterface
23-
*/
24-
private $eventManager;
25-
26-
/**
27-
* @var array
28-
*/
29-
private $identities = [];
30-
31-
/**
32-
* @param ManagerInterface $eventManager
33-
*/
34-
public function __construct(ManagerInterface $eventManager)
35-
{
36-
$this->eventManager = $eventManager;
37-
}
38-
3917
/**
4018
* Clean cache by relevant tags after entity save.
4119
*
4220
* @param Attribute $subject
43-
* @param Attribute $result
44-
*
45-
* @return Attribute
46-
*/
47-
public function afterSave(Attribute $subject, Attribute $result): Attribute
48-
{
49-
if (!$subject->isObjectNew()) {
50-
$this->triggerCacheClean($subject);
51-
}
52-
return $result;
53-
}
54-
55-
/**
56-
* Clean cache by relevant tags after entity is deleted and afterDelete handler is executed.
57-
*
58-
* @param Attribute $subject
59-
* @param Attribute $result
21+
* @param array $result
6022
*
6123
* @return Attribute
6224
*/
63-
public function afterAfterDelete(Attribute $subject, Attribute $result) : Attribute
64-
{
65-
$this->triggerCacheClean($subject);
66-
return $result;
67-
}
68-
69-
/**
70-
* Trigger cache clean event in event manager.
71-
*
72-
* @param Attribute $entity
73-
* @return void
74-
*/
75-
private function triggerCacheClean(Attribute $entity): void
25+
public function afterGetIdentities(Attribute $subject, array $result): array
7626
{
77-
$this->identities[] = sprintf(
78-
"%s_%s",
79-
Attribute::CACHE_TAG,
80-
$entity->getAttributeCode()
27+
return array_merge(
28+
$result,
29+
[
30+
sprintf(
31+
"%s_%s",
32+
Attribute::CACHE_TAG,
33+
$subject->getAttributeCode()
34+
)
35+
]
8136
);
82-
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this]);
83-
}
84-
85-
/**
86-
* @inheritDoc
87-
*/
88-
public function getIdentities()
89-
{
90-
return $this->identities;
9137
}
9238
}

0 commit comments

Comments
 (0)