|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * ScandiPWA - Progressive Web App for Magento |
| 4 | + * |
| 5 | + * Copyright © Scandiweb, Inc. All rights reserved. |
| 6 | + * See LICENSE for license details. |
| 7 | + * |
| 8 | + * @license OSL-3.0 (Open Software License ("OSL") v. 3.0) |
| 9 | + * @package scandipwa/module-customer-graph-ql |
| 10 | + * @link https://github.com/scandipwa/module-customer-graph-ql |
| 11 | + */ |
| 12 | +declare(strict_types=1); |
| 13 | + |
| 14 | +namespace ScandiPWA\CustomerGraphQl\Model\Resolver; |
| 15 | + |
| 16 | +use Magento\Customer\Api\AccountManagementInterface; |
| 17 | +use Magento\Framework\GraphQl\Config\Element\Field; |
| 18 | +use Magento\Framework\GraphQl\Query\ResolverInterface; |
| 19 | +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; |
| 20 | + |
| 21 | +class CheckIsEmailAvailable implements ResolverInterface { |
| 22 | + /** |
| 23 | + * @var \Magento\Customer\Api\AccountManagementInterface |
| 24 | + */ |
| 25 | + protected $accountManagement; |
| 26 | + |
| 27 | + /** |
| 28 | + * ResendConfirmationEmail constructor. |
| 29 | + * @param AccountManagementInterface $accountManagement |
| 30 | + */ |
| 31 | + public function __construct( |
| 32 | + AccountManagementInterface $accountManagement |
| 33 | + ) { |
| 34 | + $this->accountManagement = $accountManagement; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @inheritdoc |
| 39 | + */ |
| 40 | + public function resolve( |
| 41 | + Field $field, |
| 42 | + $context, |
| 43 | + ResolveInfo $info, |
| 44 | + array $value = null, |
| 45 | + array $args = null |
| 46 | + ) { |
| 47 | + $email = $args['email']; |
| 48 | + $websiteId = isset($args['websiteId']) ? $args['websiteId'] : null; |
| 49 | + |
| 50 | + $result = $this->accountManagement->isEmailAvailable( |
| 51 | + $email, |
| 52 | + $websiteId |
| 53 | + ); |
| 54 | + |
| 55 | + return ['isAvailable' => $result]; |
| 56 | + } |
| 57 | +} |
0 commit comments