|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Client\FactFinderSdk\Business\Api\Converter; |
|
9
|
|
|
|
|
10
|
|
|
use FACTFinder\Adapter\Recommendation as FactFinderRecommendationAdapter; |
|
11
|
|
|
use FACTFinder\Data\Record; |
|
12
|
|
|
use Generated\Shared\Transfer\FactFinderSdkRecommendationResponseTransfer; |
|
|
|
|
|
|
13
|
|
|
use SprykerEco\Client\FactFinderSdk\FactFinderSdkConfig; |
|
14
|
|
|
|
|
15
|
|
|
class RecommendationResponseConverter extends BaseConverter implements ConverterInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var \FACTFinder\Adapter\Recommendation |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $recommendationAdapter; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var \SprykerEco\Client\FactFinderSdk\FactFinderSdkConfig |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $factFinderSdkConfig; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param \FACTFinder\Adapter\Recommendation $recommendationAdapter |
|
29
|
|
|
* @param \SprykerEco\Client\FactFinderSdk\FactFinderSdkConfig $factFinderSdkConfig |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(FactFinderRecommendationAdapter $recommendationAdapter, FactFinderSdkConfig $factFinderSdkConfig) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->recommendationAdapter = $recommendationAdapter; |
|
34
|
|
|
$this->factFinderSdkConfig = $factFinderSdkConfig; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return \Generated\Shared\Transfer\FactFinderSdkRecommendationResponseTransfer |
|
39
|
|
|
*/ |
|
40
|
|
|
public function convert() |
|
41
|
|
|
{ |
|
42
|
|
|
$responseTransfer = new FactFinderSdkRecommendationResponseTransfer(); |
|
43
|
|
|
|
|
44
|
|
|
$recommendations = $this->recommendationAdapter |
|
45
|
|
|
->getRecommendations(); |
|
46
|
|
|
|
|
47
|
|
|
if ($recommendations->count()) { |
|
48
|
|
|
foreach ($recommendations as $recommendation) { |
|
49
|
|
|
$recommendationData = $this->getRecommendationData($recommendation); |
|
50
|
|
|
$responseTransfer->addRecommendations($recommendationData); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
return $responseTransfer; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param \FACTFinder\Data\Record $recommendation |
|
59
|
|
|
* |
|
60
|
|
|
* @return array |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function getRecommendationData(Record $recommendation) |
|
63
|
|
|
{ |
|
64
|
|
|
$result = []; |
|
65
|
|
|
|
|
66
|
|
|
$result['position'] = $recommendation->getPosition(); |
|
67
|
|
|
$result['seoPath'] = $recommendation->getSeoPath(); |
|
68
|
|
|
$result['keywords'] = $recommendation->getKeywords(); |
|
69
|
|
|
$result['similarity'] = $recommendation->getSimilarity(); |
|
70
|
|
|
$result['id'] = $recommendation->getID(); |
|
71
|
|
|
$result['fields'] = $this->getFields($recommendation); |
|
72
|
|
|
|
|
73
|
|
|
return $result; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param \FACTFinder\Data\Record $recommendation |
|
78
|
|
|
* |
|
79
|
|
|
* @return array |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function getFields(Record $recommendation) |
|
82
|
|
|
{ |
|
83
|
|
|
$fields = []; |
|
84
|
|
|
|
|
85
|
|
|
foreach ($this->factFinderSdkConfig->getItemFields() as $fieldName) { |
|
86
|
|
|
$fields[$fieldName] = $recommendation->getField($fieldName); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return $fields; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
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