|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\AkeneoPimMiddlewareConnector\Business\Translator\TranslatorFunction; |
|
9
|
|
|
|
|
10
|
|
|
use Iterator; |
|
11
|
|
|
use SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Service\AkeneoPimMiddlewareConnectorToAkeneoPimServiceInterface; |
|
12
|
|
|
use SprykerMiddleware\Zed\Process\Business\Translator\TranslatorFunction\AbstractTranslatorFunction; |
|
|
|
|
|
|
13
|
|
|
use SprykerMiddleware\Zed\Process\Business\Translator\TranslatorFunction\TranslatorFunctionInterface; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class AddAttributeOptions extends AbstractTranslatorFunction implements TranslatorFunctionInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var array |
|
19
|
|
|
*/ |
|
20
|
|
|
protected const ATTRIBUTE_TYPES_WITH_OPTIONS = [ |
|
21
|
|
|
'pim_catalog_simpleselect', |
|
22
|
|
|
'pim_catalog_multiselect', |
|
23
|
|
|
]; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Service\AkeneoPimMiddlewareConnectorToAkeneoPimServiceInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
private $akeneoPimService; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param \SprykerEco\Zed\AkeneoPimMiddlewareConnector\Dependency\Service\AkeneoPimMiddlewareConnectorToAkeneoPimServiceInterface $akeneoPimService |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct(AkeneoPimMiddlewareConnectorToAkeneoPimServiceInterface $akeneoPimService) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->akeneoPimService = $akeneoPimService; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param mixed $value |
|
40
|
|
|
* @param array $payload |
|
41
|
|
|
* |
|
42
|
|
|
* @return array |
|
43
|
|
|
*/ |
|
44
|
|
|
public function translate($value, array $payload): array |
|
45
|
|
|
{ |
|
46
|
|
|
if (!in_array($value['type'], static::ATTRIBUTE_TYPES_WITH_OPTIONS)) { |
|
47
|
|
|
return []; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return $this->getAttributeOptions($value['code']); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param string $code |
|
55
|
|
|
* |
|
56
|
|
|
* @return array |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function getAttributeOptions(string $code): array |
|
59
|
|
|
{ |
|
60
|
|
|
$options = []; |
|
61
|
|
|
foreach ($this->getIterator($code) as $option) { |
|
62
|
|
|
$options[$option['code']] = $option['labels']; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return $options; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param string $code |
|
70
|
|
|
* |
|
71
|
|
|
* @return \Iterator |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function getIterator(string $code): Iterator |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->akeneoPimService->getAllAttributeOptions($code, $this->options['pageSize'] ?? 100); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths