Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-customer-graph-ql
Model
Resolver
Customer.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\CustomerGraphQl\Model\Resolver
;
9
10
use
Magento\Authorization\Model\UserContextInterface
;
11
use
Magento\Framework\GraphQl\Schema\Type\ResolveInfo
;
12
use
Magento\CustomerGraphQl\Model\Resolver\Customer\CustomerDataProvider
;
13
use
Magento\Framework\Exception\NoSuchEntityException
;
14
use
Magento\Framework\GraphQl\Config\Element\Field
;
15
use
Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException
;
16
use
Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException
;
17
use
Magento\Framework\GraphQl\Query\Resolver\ContextInterface
;
18
use
Magento\Framework\GraphQl\Query\ResolverInterface
;
19
23
class
Customer
implements
ResolverInterface
24
{
28
private
$customerResolver;
29
33
public
function
__construct
(
34
CustomerDataProvider
$customerResolver
35
) {
36
$this->customerResolver = $customerResolver;
37
}
38
42
public
function
resolve
(
43
Field
$field,
44
$context,
45
ResolveInfo
$info
,
46
array
$value
=
null
,
47
array $args =
null
48
) {
50
if
((!$context->getUserId()) || $context->getUserType() ==
UserContextInterface::USER_TYPE_GUEST
) {
51
throw
new
GraphQlAuthorizationException
(
52
__
(
53
'Current customer does not have access to the resource "%1"'
,
54
[\
Magento
\
Customer
\Model\Customer::ENTITY]
55
)
56
);
57
}
58
59
try
{
60
$data
= $this->customerResolver->getCustomerById($context->getUserId());
61
return
!empty(
$data
) ?
$data
: [];
62
}
catch
(NoSuchEntityException $exception) {
63
throw
new
GraphQlNoSuchEntityException(
__
(
'Customer id %1 does not exist.'
, [$context->getUserId()]));
64
}
65
}
66
}
Magento\Framework\GraphQl\Query\ResolverInterface
Definition:
ResolverInterface.php:18
Magento\Framework\GraphQl\Query\Resolver\ContextInterface
Definition:
ContextInterface.php:19
Magento\Authorization\Model\UserContextInterface\USER_TYPE_GUEST
const USER_TYPE_GUEST
Definition:
UserContextInterface.php:23
Magento\Framework\GraphQl\Schema\Type\ResolveInfo
Definition:
ResolveInfo.php:13
Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException
Definition:
GraphQlAuthorizationException.php:16
Magento\Authorization\Model\UserContextInterface
Definition:
UserContextInterface.php:15
__
__()
Definition:
__.php:13
Magento\Framework\GraphQl\Config\Element\Field
Definition:
Field.php:15
Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException
Definition:
GraphQlNoSuchEntityException.php:16
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
$value
$value
Definition:
gender.phtml:16
Magento\CustomerGraphQl\Model\Resolver\Customer
Definition:
Customer.php:23
Magento\CustomerGraphQl\Model\Resolver
Magento
$info
foreach( $_productCollection as $_product)() ?>" class $info
Definition:
listing.phtml:52
Magento\CustomerGraphQl\Model\Resolver\Customer\__construct
__construct(CustomerDataProvider $customerResolver)
Definition:
Customer.php:33
Magento\Framework\GraphQl\Query\ResolverInterface\resolve
resolve(Field $field, $context, ResolveInfo $info, array $value=null, array $args=null)
Magento\CustomerGraphQl\Model\Resolver\Customer\CustomerDataProvider
Definition:
CustomerDataProvider.php:20
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16