-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGet.php
64 lines (57 loc) · 1.6 KB
/
Get.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
namespace Kiboko\Plugin\Akeneo\Capacity\Extractor;
use Kiboko\Plugin\Akeneo;
use PhpParser\Builder;
use PhpParser\Node;
final class Get implements Akeneo\Capacity\CapacityInterface
{
private static array $endpoints = [
// Core Endpoints
'product',
'category',
'attribute',
'attributeOption',
'attributeGroup',
'family',
'productMediaFile',
'locale',
'channel',
'currency',
'measureFamily',
'associationType',
'familyVariant',
'productModel',
// Enterprise Endpoints
'publishedProduct',
'productModelDraft',
'productDraft',
'asset',
'assetCategory',
'assetTag',
'referenceEntityRecord',
'referenceEntityAttribute',
'referenceEntityAttributeOption',
'referenceEntity',
'assetManager',
];
public function __construct(
private readonly Akeneo\Handler\EndpointHandlerFactoryInterface $factory,
) {
}
public function applies(array $config): bool
{
return isset($config['type'])
&& \in_array($config['type'], self::$endpoints)
&& isset($config['method'])
&& 'get' === $config['method'];
}
public function getBuilder(array $config): Builder
{
return (new Akeneo\Builder\Capacity\Extractor\Get($this->factory->create($config['type'], $config)))
->withEndpoint(
new Node\Identifier(sprintf('get%sApi', ucfirst((string) $config['type']))),
)
;
}
}