Skip to content

Commit f60294e

Browse files
committed
ACPT-1688: Fix Static Tests failures on Application-Server branch;
-Remove dependency of library classes on non-library classes
1 parent 300eb43 commit f60294e

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogGraphQl\Plugin\Search;
8+
9+
use Magento\CatalogGraphQl\DataProvider\Product\RequestDataBuilder;
10+
use Magento\Framework\Search\Request\Config;
11+
12+
class RequestBuilderPlugin
13+
{
14+
public function __construct(private RequestDataBuilder $localData)
15+
{
16+
}
17+
18+
/**
19+
* @param Config $subject
20+
* @param callable $proceed
21+
* @param string $requestName
22+
* @return array
23+
*/
24+
public function aroundGet(Config $subject, callable $proceed, string $requestName) {
25+
26+
if ($this->localData->getData($requestName)) {
27+
return $this->localData->getData($requestName);
28+
} else {
29+
return $proceed($requestName);
30+
}
31+
}
32+
}

app/code/Magento/CatalogGraphQl/etc/di.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
</argument>
102102
</arguments>
103103
</type>
104-
104+
<type name="Magento\Framework\Search\Request\Config">
105+
<plugin name="localRequestDataPlugin" type="Magento\CatalogGraphQl\Plugin\Search\RequestBuilderPlugin" />
106+
</type>
105107
<type name="Magento\Framework\Search\Request\Config\FilesystemReader">
106108
<plugin name="productAttributesDynamicFields" type="Magento\CatalogGraphQl\Plugin\Search\Request\ConfigReader" />
107109
</type>

lib/internal/Magento/Framework/Search/Request/Builder.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Framework\Search\Request;
88

9-
use Magento\CatalogGraphQl\DataProvider\Product\RequestDataBuilder;
109
use Magento\Framework\Api\SortOrder;
1110
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1211
use Magento\Framework\ObjectManagerInterface;
@@ -50,32 +49,24 @@ class Builder implements ResetAfterRequestInterface
5049
*/
5150
private $cleaner;
5251

53-
/**
54-
* @var RequestDataBuilder|mixed
55-
*/
56-
private RequestDataBuilder $localData;
57-
5852
/**
5953
* Request Builder constructor
6054
*
6155
* @param ObjectManagerInterface $objectManager
6256
* @param Config $config
6357
* @param Binder $binder
6458
* @param Cleaner $cleaner
65-
* @param RequestDataBuilder|null $localData
6659
*/
6760
public function __construct(
6861
ObjectManagerInterface $objectManager,
6962
Config $config,
7063
Binder $binder,
71-
Cleaner $cleaner,
72-
RequestDataBuilder $localData = null
64+
Cleaner $cleaner
7365
) {
7466
$this->objectManager = $objectManager;
7567
$this->config = $config;
7668
$this->binder = $binder;
7769
$this->cleaner = $cleaner;
78-
$this->localData = $localData ?? $this->objectManager->get(RequestDataBuilder::class);
7970
}
8071

8172
/**
@@ -164,12 +155,9 @@ public function create()
164155
throw new \InvalidArgumentException("Request name not defined.");
165156
}
166157
$requestName = $this->data['requestName'];
167-
if ($this->localData->getData($requestName)) {
168-
$data = $this->localData->getData($requestName);
169-
} else {
170-
/** @var array $data */
171-
$data = $this->config->get($requestName);
172-
}
158+
/** @var array $data */
159+
$data = $this->config->get($requestName);
160+
173161
if ($data === null) {
174162
throw new NonExistingRequestNameException(new Phrase("Request name '%1' doesn't exist.", [$requestName]));
175163
}

0 commit comments

Comments
 (0)