-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graphQl-44: added html content resolver
- Loading branch information
vitaliyboyko
committed
Oct 23, 2018
1 parent
80669e3
commit a18a087
Showing
6 changed files
with
61 additions
and
212 deletions.
There are no files selected for viewing
64 changes: 0 additions & 64 deletions
64
app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductTextAttribute.php
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...de/Magento/CatalogGraphQl/Model/Resolver/Product/ProductTextAttribute/FormatInterface.php
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductTextAttribute/FormatList.php
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductTextAttribute/Html.php
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
app/code/Magento/CatalogGraphQl/Model/Resolver/Product/ProductTextAttribute/HtmlContent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogGraphQl\Model\Resolver\Product\ProductTextAttribute; | ||
|
||
use Magento\Catalog\Model\Product; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\Catalog\Helper\Output as OutputHelper; | ||
|
||
/** | ||
* HTML content of Product Text Attribute | ||
*/ | ||
class HtmlContent implements ResolverInterface | ||
{ | ||
/** | ||
* @var OutputHelper | ||
*/ | ||
private $outputHelper; | ||
|
||
/** | ||
* @param OutputHelper $outputHelper | ||
*/ | ||
public function __construct( | ||
OutputHelper $outputHelper | ||
) { | ||
$this->outputHelper = $outputHelper; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
): array { | ||
if (!isset($value['model'])) { | ||
return []; | ||
} | ||
|
||
/* @var $product Product */ | ||
$product = $value['model']; | ||
$fieldName = $field->getName(); | ||
$renderedValue = $this->outputHelper->productAttribute($product, $product->getData($fieldName), $fieldName); | ||
|
||
return $renderedValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters