Files

59 lines
1.8 KiB
PHP

<?php
/************************************************************************
*
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
* ************************************************************************
*/
declare(strict_types=1);
namespace Magento\CustomerGraphQl\Model\Resolver;
use Magento\Customer\Api\AccountManagementInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
/**
* Confirmation status resolver
*/
class ConfirmationStatus implements ResolverInterface
{
/**
* @param AccountManagementInterface $accountManagement
*/
public function __construct(
private readonly AccountManagementInterface $accountManagement
) {
}
/**
* @inheritdoc
*/
public function resolve(
Field $field,
$context,
ResolveInfo $info,
array $value = null,
array $args = null
) {
try {
$confirmationStatus = $this->accountManagement->getConfirmationStatus($context->getUserId());
} catch (LocalizedException $e) {
throw new GraphQlInputException(__($e->getMessage()), $e);
}
return strtoupper($confirmationStatus);
}
}