-
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] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #28210: #257: create new id_v2 option (by @mmezhensky)
- Loading branch information
Showing
13 changed files
with
663 additions
and
5 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
app/code/Magento/BundleGraphQl/Model/Resolver/Options/BundleItemOptionUid.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,68 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\BundleGraphQl\Model\Resolver\Options; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
/** | ||
* Format new option uid in base64 encode for entered bundle options | ||
*/ | ||
class BundleItemOptionUid implements ResolverInterface | ||
{ | ||
/** | ||
* Option type name | ||
*/ | ||
private const OPTION_TYPE = 'bundle'; | ||
|
||
/** | ||
* Create a option uid for entered option in "<option-type>/<option-id>/<option-value-id>/<quantity>" format | ||
* | ||
* @param Field $field | ||
* @param ContextInterface $context | ||
* @param ResolveInfo $info | ||
* @param array|null $value | ||
* @param array|null $args | ||
* | ||
* @return string | ||
* | ||
* @throws GraphQlInputException | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
if (!isset($value['option_id']) || empty($value['option_id'])) { | ||
throw new GraphQlInputException(__('"option_id" value should be specified.')); | ||
} | ||
|
||
if (!isset($value['selection_id']) || empty($value['selection_id'])) { | ||
throw new GraphQlInputException(__('"selection_id" value should be specified.')); | ||
} | ||
|
||
$optionDetails = [ | ||
self::OPTION_TYPE, | ||
$value['option_id'], | ||
$value['selection_id'], | ||
(int) $value['selection_qty'] | ||
]; | ||
|
||
$content = implode('/', $optionDetails); | ||
|
||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
return base64_encode($content); | ||
} | ||
} |
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
62 changes: 62 additions & 0 deletions
62
app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CustomizableEnteredOptionValueUid.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,62 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogGraphQl\Model\Resolver\Product; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
/** | ||
* Format new option uid in base64 encode for entered custom options | ||
*/ | ||
class CustomizableEnteredOptionValueUid implements ResolverInterface | ||
{ | ||
/** | ||
* Option type name | ||
*/ | ||
private const OPTION_TYPE = 'custom-option'; | ||
|
||
/** | ||
* Create a option uid for entered option in "<option-type>/<option-id>" format | ||
* | ||
* @param Field $field | ||
* @param ContextInterface $context | ||
* @param ResolveInfo $info | ||
* @param array|null $value | ||
* @param array|null $args | ||
* | ||
* @return string | ||
* | ||
* @throws GraphQlInputException | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
if (!isset($value['option_id']) || empty($value['option_id'])) { | ||
throw new GraphQlInputException(__('"option_id" value should be specified.')); | ||
} | ||
|
||
$optionDetails = [ | ||
self::OPTION_TYPE, | ||
$value['option_id'] | ||
]; | ||
|
||
$content = implode('/', $optionDetails); | ||
|
||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
return base64_encode($content); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...code/Magento/CatalogGraphQl/Model/Resolver/Product/CustomizableSelectedOptionValueUid.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,67 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogGraphQl\Model\Resolver\Product; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
/** | ||
* Format new option uid in base64 encode for selected custom options | ||
*/ | ||
class CustomizableSelectedOptionValueUid implements ResolverInterface | ||
{ | ||
/** | ||
* Option type name | ||
*/ | ||
private const OPTION_TYPE = 'custom-option'; | ||
|
||
/** | ||
* Create a option uid for selected option in "<option-type>/<option-id>/<option-value-id>" format | ||
* | ||
* @param Field $field | ||
* @param ContextInterface $context | ||
* @param ResolveInfo $info | ||
* @param array|null $value | ||
* @param array|null $args | ||
* | ||
* @return string | ||
* | ||
* @throws GraphQlInputException | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
if (!isset($value['option_id']) || empty($value['option_id'])) { | ||
throw new GraphQlInputException(__('"option_id" value should be specified.')); | ||
} | ||
|
||
if (!isset($value['option_type_id']) || empty($value['option_type_id'])) { | ||
throw new GraphQlInputException(__('"option_type_id" value should be specified.')); | ||
} | ||
|
||
$optionDetails = [ | ||
self::OPTION_TYPE, | ||
$value['option_id'], | ||
$value['option_type_id'] | ||
]; | ||
|
||
$content = implode('/', $optionDetails); | ||
|
||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
return base64_encode($content); | ||
} | ||
} |
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
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
67 changes: 67 additions & 0 deletions
67
...ConfigurableProductGraphQl/Model/Resolver/Variant/Attributes/ConfigurableAttributeUid.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,67 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\ConfigurableProductGraphQl\Model\Resolver\Variant\Attributes; | ||
|
||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
/** | ||
* Format new option uid in base64 encode for super attribute options | ||
*/ | ||
class ConfigurableAttributeUid implements ResolverInterface | ||
{ | ||
/** | ||
* Option type name | ||
*/ | ||
private const OPTION_TYPE = 'configurable'; | ||
|
||
/** | ||
* Create a option uid for super attribute in "<option-type>/<attribute-id>/<value-index>" format | ||
* | ||
* @param Field $field | ||
* @param ContextInterface $context | ||
* @param ResolveInfo $info | ||
* @param array|null $value | ||
* @param array|null $args | ||
* | ||
* @return string | ||
* | ||
* @throws GraphQlInputException | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
if (!isset($value['attribute_id']) || empty($value['attribute_id'])) { | ||
throw new GraphQlInputException(__('"attribute_id" value should be specified.')); | ||
} | ||
|
||
if (!isset($value['value_index']) || empty($value['value_index'])) { | ||
throw new GraphQlInputException(__('"value_index" value should be specified.')); | ||
} | ||
|
||
$optionDetails = [ | ||
self::OPTION_TYPE, | ||
$value['attribute_id'], | ||
$value['value_index'] | ||
]; | ||
|
||
$content = implode('/', $optionDetails); | ||
|
||
// phpcs:ignore Magento2.Functions.DiscouragedFunction | ||
return base64_encode($content); | ||
} | ||
} |
Oops, something went wrong.