|
8 | 8 | namespace Magento\EavGraphQl\Plugin\Eav;
|
9 | 9 |
|
10 | 10 | use Magento\Eav\Model\Entity\Attribute;
|
11 |
| -use Magento\Framework\DataObject\IdentityInterface; |
12 |
| -use Magento\Framework\Event\ManagerInterface; |
13 | 11 |
|
14 | 12 | /**
|
15 | 13 | * EAV plugin runs page cache clean and provides proper EAV identities.
|
16 | 14 | */
|
17 |
| -class AttributePlugin implements IdentityInterface |
| 15 | +class AttributePlugin |
18 | 16 | {
|
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 |
| - |
39 | 17 | /**
|
40 | 18 | * Clean cache by relevant tags after entity save.
|
41 | 19 | *
|
42 | 20 | * @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 |
60 | 22 | *
|
61 | 23 | * @return Attribute
|
62 | 24 | */
|
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 |
76 | 26 | {
|
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 | + ] |
81 | 36 | );
|
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; |
91 | 37 | }
|
92 | 38 | }
|
0 commit comments