SetUpUserContext.php 834 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\CustomerGraphQl\Model\Customer;
  8. use Magento\Customer\Api\Data\CustomerInterface;
  9. use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
  10. use Magento\Authorization\Model\UserContextInterface;
  11. /**
  12. * Set up user context after creating new customer account
  13. */
  14. class SetUpUserContext
  15. {
  16. /**
  17. * Set up user context after creating new customer account
  18. *
  19. * @param ContextInterface $context
  20. * @param CustomerInterface $customer
  21. */
  22. public function execute(ContextInterface $context, CustomerInterface $customer)
  23. {
  24. $context->setUserId((int)$customer->getId());
  25. $context->setUserType(UserContextInterface::USER_TYPE_CUSTOMER);
  26. }
  27. }