|
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\Handler\Request; |
|
9
|
|
|
|
|
10
|
|
|
use Exception; |
|
11
|
|
|
use FACTFinder\Util\Parameters; |
|
12
|
|
|
use Generated\Shared\Transfer\FactFinderSdkSearchRequestTransfer; |
|
|
|
|
|
|
13
|
|
|
use Generated\Shared\Transfer\FactFinderSdkSearchResponseTransfer; |
|
|
|
|
|
|
14
|
|
|
use SprykerEco\Client\FactFinderSdk\Business\Api\ApiConstants; |
|
15
|
|
|
|
|
16
|
|
|
class SearchRequest extends AbstractRequest implements SearchRequestInterface |
|
17
|
|
|
{ |
|
18
|
|
|
public const TRANSACTION_TYPE = ApiConstants::TRANSACTION_TYPE_SEARCH; |
|
19
|
|
|
public const REQUEST_CATEGORY_PATH_ROOT_NAME = 'filterCategoryPathROOT'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param \Generated\Shared\Transfer\FactFinderSdkSearchRequestTransfer $factFinderSearchRequestTransfer |
|
23
|
|
|
* |
|
24
|
|
|
* @return \Generated\Shared\Transfer\FactFinderSdkSearchResponseTransfer |
|
25
|
|
|
*/ |
|
26
|
|
|
public function request(FactFinderSdkSearchRequestTransfer $factFinderSearchRequestTransfer) |
|
27
|
|
|
{ |
|
28
|
|
|
$requestParameters = $this->factFinderConnector |
|
29
|
|
|
->createRequestParametersFromSearchRequestTransfer($factFinderSearchRequestTransfer); |
|
30
|
|
|
$requestParameters = $this->convertCategoryParameters($requestParameters); |
|
31
|
|
|
$this->factFinderConnector->setRequestParameters($requestParameters); |
|
32
|
|
|
|
|
33
|
|
|
$searchAdapter = $this->factFinderConnector->createSearchAdapter(); |
|
34
|
|
|
|
|
35
|
|
|
try { |
|
36
|
|
|
$responseTransfer = $this->converterFactory |
|
37
|
|
|
->createSearchResponseConverter($searchAdapter) |
|
38
|
|
|
->convert(); |
|
39
|
|
|
} catch (Exception $e) { |
|
40
|
|
|
$responseTransfer = new FactFinderSdkSearchResponseTransfer(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return $responseTransfer; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param \FACTFinder\Util\Parameters $parameters |
|
48
|
|
|
* |
|
49
|
|
|
* @return \FACTFinder\Util\Parameters |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function convertCategoryParameters(Parameters $parameters) |
|
52
|
|
|
{ |
|
53
|
|
|
$parametersArray = $parameters->getArray(); |
|
54
|
|
|
|
|
55
|
|
|
foreach ($parametersArray as $key => $parameter) { |
|
56
|
|
|
if (strpos($key, static::REQUEST_CATEGORY_PATH_ROOT_NAME) !== false) { |
|
57
|
|
|
unset($parametersArray[$key]); |
|
58
|
|
|
$newKey = str_replace('_', ' ', $key); |
|
59
|
|
|
$parametersArray[$newKey] = $parameter; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
$parameters->clear(); |
|
64
|
|
|
$parameters->setAll($parametersArray); |
|
65
|
|
|
|
|
66
|
|
|
return $parameters; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
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