Exemple #1
0
 /**
  * @param string $formCode
  * @param RequestInterface $request
  * @return \Magento\Customer\Service\V1\Data\Customer
  */
 public function extract($formCode, RequestInterface $request)
 {
     $customerForm = $this->formFactory->create('customer', $formCode);
     $allowedAttributes = $customerForm->getAllowedAttributes();
     $isGroupIdEmpty = true;
     $customerData = array();
     foreach ($allowedAttributes as $attribute) {
         // confirmation in request param is the repeated password, not a confirmation code.
         if ($attribute === 'confirmation') {
             continue;
         }
         $attributeCode = $attribute->getAttributeCode();
         if ($attributeCode == 'group_id') {
             $isGroupIdEmpty = false;
         }
         $customerData[$attributeCode] = $request->getParam($attributeCode);
     }
     $this->customerBuilder->populateWithArray($customerData);
     $store = $this->storeManager->getStore();
     if ($isGroupIdEmpty) {
         $this->customerBuilder->setGroupId($this->groupService->getDefaultGroup($store->getId())->getId());
     }
     $this->customerBuilder->setWebsiteId($store->getWebsiteId());
     $this->customerBuilder->setStoreId($store->getId());
     return $this->customerBuilder->create();
 }