6 declare(strict_types=1);
13 use Magento\Customer\Api\Data\RegionInterfaceFactory;
18 use Magento\Customer\Model\Session\Proxy as SessionProxy;
19 use Magento\Customer\Model\Delegation\Data\NewOperationFactory;
20 use Magento\Customer\Api\Data\CustomerInterfaceFactory;
21 use Magento\Customer\Api\Data\AddressInterfaceFactory;
22 use Psr\Log\LoggerInterface;
42 private $customerFactory;
47 private $addressFactory;
52 private $regionFactory;
68 NewOperationFactory $newFactory,
69 CustomerInterfaceFactory $customerFactory,
70 AddressInterfaceFactory $addressFactory,
71 RegionInterfaceFactory $regionFactory,
72 LoggerInterface $logger,
75 $this->newFactory = $newFactory;
78 $this->regionFactory = $regionFactory;
99 $addressesData[] =
$address->__toArray();
103 $this->session->setDelegatedNewCustomerData([
105 'addresses' => $addressesData,
106 'delegated_data' => $delegatedData,
115 public function consumeNewOperation()
118 $serialized = $this->session->getDelegatedNewCustomerData(
true);
119 }
catch (\Throwable $exception) {
120 $this->logger->error($exception);
123 if ($serialized ===
null) {
132 $region = $this->regionFactory->create(
144 return $this->newFactory->create([
145 'customer' => $this->customerFactory->create(
148 'additionalData' => $serialized[
'delegated_data'],
__construct(NewOperationFactory $newFactory, CustomerInterfaceFactory $customerFactory, AddressInterfaceFactory $addressFactory, RegionInterfaceFactory $regionFactory, LoggerInterface $logger, SessionProxy $session)