Skip to content

Commit 75b0da5

Browse files
committed
LYNX-100: Refactoring; bugfixing
1 parent 4970798 commit 75b0da5

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

app/code/Magento/EavGraphQl/Model/Resolver/AttributesList.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1515
use Magento\Framework\GraphQl\Query\ResolverInterface;
1616
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
17-
use Magento\EavGraphQl\Model\Output\GetAttributeData;
17+
use Magento\Framework\Exception\RuntimeException;
1818
use Magento\EavGraphQl\Model\Output\GetAttributeDataInterface;
1919

2020
/**
@@ -45,27 +45,27 @@ class AttributesList implements ResolverInterface
4545
/**
4646
* @var array
4747
*/
48-
private array $resolvers;
48+
private array $searchCriteriaProviders;
4949

5050
/**
5151
* @param AttributeRepository $attributeRepository
5252
* @param SearchCriteriaBuilder $searchCriteriaBuilder
5353
* @param EnumLookup $enumLookup
5454
* @param GetAttributeDataInterface $getAttributeData
55-
* @param array $resolvers
55+
* @param array $searchCriteriaProviders
5656
*/
5757
public function __construct(
5858
AttributeRepository $attributeRepository,
5959
SearchCriteriaBuilder $searchCriteriaBuilder,
6060
EnumLookup $enumLookup,
6161
GetAttributeDataInterface $getAttributeData,
62-
array $resolvers = []
62+
array $searchCriteriaProviders = []
6363
) {
6464
$this->attributeRepository = $attributeRepository;
6565
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
6666
$this->enumLookup = $enumLookup;
6767
$this->getAttributeData = $getAttributeData;
68-
$this->resolvers = $resolvers;
68+
$this->searchCriteriaProviders = $searchCriteriaProviders;
6969
}
7070

7171
/**
@@ -90,8 +90,13 @@ public function resolve(
9090
);
9191

9292
$searchCriteria = $this->searchCriteriaBuilder;
93-
foreach ($this->resolvers as $resolver) {
94-
$searchCriteria->addFilter($resolver['name'], $resolver['object']->execute());
93+
foreach ($this->searchCriteriaProviders as $key => $provider) {
94+
if (!$provider instanceof ResolverInterface) {
95+
throw new RuntimeException(
96+
__('Configured search criteria provider should implement ResolverInterface')
97+
);
98+
}
99+
$searchCriteria->addFilter($key, $provider->resolve($field, $context, $info));
95100
}
96101
$searchCriteria = $searchCriteria->create();
97102

0 commit comments

Comments
 (0)