Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 1f9c09e

Browse files
author
Roman Glushko
committed
#31 Refactored the code & committed composer.lock
1 parent 9b26913 commit 1f9c09e

File tree

4 files changed

+518
-455
lines changed

4 files changed

+518
-455
lines changed

app/code/Magento/CmsGraphQl/Model/Resolver/Cms/CmsPageDataProvider.php

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,17 @@
1919
*/
2020
class CmsPageDataProvider
2121
{
22-
/**
23-
* @var ServiceOutputProcessor
24-
*/
25-
private $serviceOutputProcessor;
26-
27-
/**
28-
* @var SerializerInterface
29-
*/
30-
private $jsonSerializer;
31-
3222
/**
3323
* @var CmsPageRepositoryInterface
3424
*/
3525
private $cmsPageRepository;
3626

3727
/**
3828
* @param CmsPageRepositoryInterface $cmsPageRepository
39-
* @param ServiceOutputProcessor $serviceOutputProcessor
40-
* @param SerializerInterface $jsonSerializer
4129
*/
4230
public function __construct(
43-
CmsPageRepositoryInterface $cmsPageRepository,
44-
ServiceOutputProcessor $serviceOutputProcessor,
45-
SerializerInterface $jsonSerializer
31+
CmsPageRepositoryInterface $cmsPageRepository
4632
) {
47-
$this->serviceOutputProcessor = $serviceOutputProcessor;
48-
$this->jsonSerializer = $jsonSerializer;
4933
$this->cmsPageRepository = $cmsPageRepository;
5034
}
5135

@@ -92,54 +76,6 @@ private function processCmsPage(CmsPageInterface $cmsPageModel) : array
9276
'mate_keywords' => $cmsPageModel->getMetaKeywords(),
9377
];
9478

95-
if (isset($cmsPageData['extension_attributes'])) {
96-
$cmsPageData = array_merge($cmsPageData, $cmsPageData['extension_attributes']);
97-
}
98-
99-
if (isset($cmsPageData['custom_attributes'])) {
100-
$cmsPageData = array_merge($cmsPageData, $this->processCustomAttributes($cmsPageData['custom_attributes']));
101-
}
102-
10379
return $cmsPageData;
10480
}
105-
106-
/**
107-
* @param array $customAttributes
108-
*
109-
* @return array
110-
*/
111-
private function processCustomAttributes(array $customAttributes) : array
112-
{
113-
$processedCustomAttributes = [];
114-
115-
foreach ($customAttributes as $customAttribute) {
116-
$isArray = false;
117-
$customAttributeCode = $customAttribute['attribute_code'];
118-
$customAttributeValue = $customAttribute['attribute_code'];
119-
120-
if (is_array($customAttributeValue)) {
121-
$isArray = true;
122-
123-
foreach ($customAttributeValue as $attributeValue) {
124-
if (is_array($attributeValue)) {
125-
$processedCustomAttributes[$customAttributeCode] = $this->jsonSerializer->serialize(
126-
$customAttributeValue
127-
);
128-
continue;
129-
}
130-
$processedCustomAttributes[$customAttributeCode] = implode(',', $customAttributeValue);
131-
continue;
132-
}
133-
}
134-
135-
if ($isArray) {
136-
continue;
137-
}
138-
139-
$processedCustomAttributes[$customAttributeCode] = $customAttributeValue;
140-
}
141-
142-
return $processedCustomAttributes;
143-
}
144-
14581
}

app/code/Magento/CmsGraphQl/Model/Resolver/CmsPage.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@
77

88
namespace Magento\CmsGraphQl\Model\Resolver;
99

10-
use Magento\Authorization\Model\UserContextInterface;
1110
use Magento\CmsGraphQl\Model\Resolver\Cms\CmsPageDataProvider;
12-
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
13-
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
14-
use Magento\CustomerGraphQl\Model\Resolver\Customer\CustomerDataProvider;
1511
use Magento\Framework\Exception\NoSuchEntityException;
1612
use Magento\Framework\GraphQl\Config\Element\Field;
17-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
13+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1814
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
19-
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
2015
use Magento\Framework\GraphQl\Query\Resolver\Value;
2116
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
2217
use Magento\Framework\GraphQl\Query\ResolverInterface;
18+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
2319

2420
/**
2521
* CMS page field resolver, used for GraphQL request processing.

app/code/Magento/CmsGraphQl/etc/module.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<module name="Magento_CmsGraphQl">
1010
<sequence>
1111
<module name="Magento_Cms"/>
12-
<module name="Magento_Authorization"/>
1312
<module name="Magento_GraphQl"/>
1413
</sequence>
1514
</module>

0 commit comments

Comments
 (0)