Skip to content

Commit 1397b4f

Browse files
committed
MAGETWO-87264: Finalizing - refactoring code for Pr
1 parent 7f3fb1d commit 1397b4f

File tree

14 files changed

+24
-38
lines changed

14 files changed

+24
-38
lines changed

app/code/Magento/BundleGraphQl/Model/BundleProductTypeResolver.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@
66

77
namespace Magento\BundleGraphQl\Model;
88

9-
use Magento\Framework\GraphQl\Config\Data\TypeResolverInterface;
10-
119
/**
1210
* {@inheritdoc}
1311
*/
14-
class BundleProductTypeResolver implements TypeResolverInterface
12+
class BundleProductTypeResolver
1513
{
1614
/**
1715
* {@inheritdoc}
1816
*/
19-
public function resolveType(array $data)
17+
public function resolveType($typeId)
2018
{
21-
if (isset($data['type_id']) && $data['type_id'] == 'bundle') {
19+
if ($typeId == 'bundle') {
2220
return 'BundleProduct';
2321
}
24-
25-
return null;
2622
}
2723
}

app/code/Magento/CatalogGraphQl/Model/CatalogProductTypeResolver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class CatalogProductTypeResolver implements TypeResolverInterface
1818
*/
1919
public function resolveType(array $data)
2020
{
21-
if (isset($data['type_id']) && $data['type_id'] == 'simple') {
22-
return 'SimpleProduct';
23-
} elseif (isset($data['type_id']) && $data['type_id'] == 'virtual') {
24-
return 'VirtualProduct';
21+
if (isset($data['type_id'])) {
22+
if ($data['type_id'] == 'simple') {
23+
return 'SimpleProduct';
24+
} elseif ($data['type_id'] == 'virtual') {
25+
return 'VirtualProduct';
26+
}
2527
}
26-
27-
return null;
2828
}
2929
}

app/code/Magento/CatalogGraphQl/Model/CustomizableOptionTypeResolver.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Framework\GraphQl\Type\Entity\MapperInterface;
1111

1212
/**
13-
* Class CustomizableOptionTypeResolver
13+
* Resolve the CustomizableOptionType for graphql schema
1414
*/
1515
class CustomizableOptionTypeResolver implements TypeResolverInterface
1616
{
@@ -35,10 +35,8 @@ public function __construct(MapperInterface $mapper)
3535
public function resolveType(array $data)
3636
{
3737
$map = $this->mapper->getMappedTypes(self::ENTITY_TYPE);
38-
if (!isset($map[$data['type']]) || !isset($map[$data['type']])) {
39-
return null;
38+
if (isset($map[$data['type']])) {
39+
return $map[$data['type']];
4040
}
41-
42-
return $map[$data['type']];
4341
}
4442
}

app/code/Magento/CatalogGraphQl/Model/ProductLinkTypeResolverComposite.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ public function resolveType(array $data)
4343
}
4444
$resolvedType = $productLinksTypeNameResolvers->resolveType($data);
4545

46-
if (!$resolvedType) {
47-
throw new GraphQlInputException(
48-
__('Concrete type for %1 not implemented', ['ProductLinksInterface'])
49-
);
46+
if ($resolvedType) {
47+
return $resolvedType;
5048
}
5149
}
5250

53-
return $resolvedType;
51+
if (!$resolvedType) {
52+
throw new GraphQlInputException(
53+
__('Concrete type for %1 not implemented', ['ProductLinksInterface'])
54+
);
55+
}
5456
}
5557
}

app/code/Magento/CatalogGraphQl/Model/ProductLinksTypeResolver.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,5 @@ public function resolveType(array $data)
2929
return 'ProductLinks';
3030
}
3131
}
32-
33-
return null;
3432
}
3533
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/FilterArgument/AstConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private function getClausesFromAst(ReferenceType $referenceType, array $argument
116116
private function getCatalogProductFields()
117117
{
118118
$productTypeSchema = $this->config->getTypeStructure('SimpleProduct');
119-
if (! $productTypeSchema instanceof Type) {
119+
if (!$productTypeSchema instanceof Type) {
120120
throw new \LogicException(__("SimpleProduct type not defined in schema."));
121121
}
122122

app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@ public function resolveType(array $data)
2121
if (isset($data['type_id']) && $data['type_id'] == 'configurable') {
2222
return 'ConfigurableProduct';
2323
}
24-
25-
return null;
2624
}
2725
}

app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/Products/DataProvider/Product/Formatter/ConfigurableOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\FormatterInterface;
1212

1313
/**
14-
* Post formatting plugin to continue formatting data for configurable type products
14+
* Post formatting to continue formatting data for configurable type products
1515
*/
1616
class ConfigurableOptions implements FormatterInterface
1717
{

app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/Products/Query/ConfigurableProductPostProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\Framework\GraphQl\Query\PostFetchProcessorInterface;
1414

1515
/**
16-
* Retrieves simple product data for child products, and formats configurable data
16+
* Retrieves simple product data for child products and formats configurable data
1717
*/
1818
class ConfigurableProductPostProcessor implements PostFetchProcessorInterface
1919
{

app/code/Magento/DownloadableGraphQl/Model/DownloadableProductTypeResolver.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@ public function resolveType(array $data)
2121
if (isset($data['type_id']) && $data['type_id'] == 'downloadable') {
2222
return 'DownloadableProduct';
2323
}
24-
25-
return null;
2624
}
2725
}

0 commit comments

Comments
 (0)