-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
Copy pathAttributesFormIdentity.php
50 lines (44 loc) · 1.26 KB
/
AttributesFormIdentity.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Eav\Model\Cache;
use Magento\Framework\Api\AttributeInterface;
use Magento\Framework\GraphQl\Query\Resolver\IdentityInterface;
use Magento\Eav\Model\Entity\Attribute;
/**
* Cache identity provider for attributes form query
*/
class AttributesFormIdentity implements IdentityInterface
{
public const CACHE_TAG = 'EAV_FORM';
/**
* @inheritDoc
*/
public function getIdentities(array $resolvedData): array
{
if (empty($resolvedData['items'])) {
return [];
}
$identities = [];
if ($resolvedData['formCode'] !== '') {
$identities[] = sprintf(
"%s_%s_FORM",
self::CACHE_TAG,
$resolvedData['formCode'] ?? ''
);
}
foreach ($resolvedData['items'] as $item) {
if ($item['attribute'] instanceof AttributeInterface) {
$identities[] = sprintf(
"%s_%s",
Attribute::CACHE_TAG,
$item['attribute']->getAttributeId()
);
}
}
return $identities;
}
}