checkCustomerAccount = $checkCustomerAccount; $this->addressRepository = $addressRepository; $this->customerAddressDataProvider = $customerAddressDataProvider; $this->dataObjectHelper = $dataObjectHelper; $this->customerAddressUpdateDataValidator = $customerAddressUpdateDataValidator; $this->getCustomerAddressForUser = $getCustomerAddressForUser; } /** * @inheritdoc */ public function resolve( Field $field, $context, ResolveInfo $info, array $value = null, array $args = null ) { $currentUserId = $context->getUserId(); $currentUserType = $context->getUserType(); $this->checkCustomerAccount->execute($currentUserId, $currentUserType); $this->customerAddressUpdateDataValidator->validate($args['input']); $address = $this->updateCustomerAddress((int)$currentUserId, (int)$args['id'], $args['input']); return $this->customerAddressDataProvider->getAddressData($address); } /** * Update customer address * * @param int $customerId * @param int $addressId * @param array $addressData * @return AddressInterface */ private function updateCustomerAddress(int $customerId, int $addressId, array $addressData) { $address = $this->getCustomerAddressForUser->execute($addressId, $customerId); $this->dataObjectHelper->populateWithArray($address, $addressData, AddressInterface::class); if (isset($addressData['region']['region_id'])) { $address->setRegionId($address->getRegion()->getRegionId()); } return $this->addressRepository->save($address); } }