1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Getnet. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See LICENSE for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Getnet\SplitExampleMagento\Ui\Component\Form\Product; |
10
|
|
|
|
11
|
|
|
use Getnet\SubSellerMagento\Api\SubSellerRepositoryInterface; |
|
|
|
|
12
|
|
|
use Magento\Framework\Api\FilterBuilder; |
13
|
|
|
use Magento\Framework\Api\SearchCriteriaBuilder; |
14
|
|
|
use Magento\Framework\App\RequestInterface; |
15
|
|
|
use Magento\Framework\Data\OptionSourceInterface; |
16
|
|
|
|
17
|
|
|
class GetnetSubSellerIdOptions implements OptionSourceInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var SubSellerRepositoryInterface |
21
|
|
|
*/ |
22
|
|
|
protected $subSellerRepository; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var SearchCriteriaBuilder |
26
|
|
|
*/ |
27
|
|
|
protected $searchCriteria; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var FilterBuilder |
31
|
|
|
*/ |
32
|
|
|
protected $filterBuilder; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var RequestInterface |
36
|
|
|
*/ |
37
|
|
|
protected $request; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var array |
41
|
|
|
*/ |
42
|
|
|
protected $subSellerIdTree; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Constructor. |
46
|
|
|
* |
47
|
|
|
* @param SubSellerRepositoryInterface $subSellerRepository |
48
|
|
|
* @param SearchCriteriaBuilder $searchCriteria |
49
|
|
|
* @param FilterBuilder $filterBuilder |
50
|
|
|
* @param RequestInterface $request |
51
|
|
|
*/ |
52
|
|
|
public function __construct( |
53
|
|
|
SubSellerRepositoryInterface $subSellerRepository, |
54
|
|
|
SearchCriteriaBuilder $searchCriteria, |
55
|
|
|
FilterBuilder $filterBuilder, |
56
|
|
|
RequestInterface $request |
57
|
|
|
) { |
58
|
|
|
$this->subSellerRepository = $subSellerRepository; |
59
|
|
|
$this->searchCriteria = $searchCriteria; |
60
|
|
|
$this->filterBuilder = $filterBuilder; |
61
|
|
|
$this->request = $request; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Get Options. |
66
|
|
|
* |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
|
|
public function toOptionArray(): array |
70
|
|
|
{ |
71
|
|
|
return $this->getSubSellerIdTree(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get Options. |
76
|
|
|
* |
77
|
|
|
* @return array |
78
|
|
|
*/ |
79
|
|
|
public function getSubSellerIdTree(): array |
80
|
|
|
{ |
81
|
|
|
if ($this->subSellerIdTree === null) { |
82
|
|
|
$sellers = []; |
83
|
|
|
$searchCriteria = $this->searchCriteria->addFilters( |
84
|
|
|
[ |
85
|
|
|
$this->filterBuilder->setField('id_ext')->setValue(null)->setConditionType('neq')->create(), |
86
|
|
|
] |
87
|
|
|
)->create(); |
88
|
|
|
$subSellers = $this->subSellerRepository->getList($searchCriteria); |
89
|
|
|
|
90
|
|
|
foreach ($subSellers->getItems() as $subSeller) { |
91
|
|
|
$sellers[$subSeller->getIdExt()] = [ |
92
|
|
|
'value' => $subSeller->getIdExt(), |
93
|
|
|
'label' => sprintf( |
94
|
|
|
'%s - Código Interno: %s - Email: %s', |
95
|
|
|
$subSeller->getLegalName(), |
96
|
|
|
$subSeller->getCode(), |
97
|
|
|
$subSeller->getEmail() |
98
|
|
|
), |
99
|
|
|
]; |
100
|
|
|
} |
101
|
|
|
$this->subSellerIdTree = $sellers; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
return $this->subSellerIdTree; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
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