Skip to content

Commit

Permalink
magento#271: [My Account] Updating customer mutations validation: all…
Browse files Browse the repository at this point in the history
…owing partial customer data update
  • Loading branch information
furseyev committed Jun 22, 2019
1 parent 1c65121 commit cc69055
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function execute(array $data): CustomerInterface
*/
private function createAccount(array $data): CustomerInterface
{
$this->validateCustomerData->execute($data);
$this->validateCustomerData->execute($data, true);
$customerDataObject = $this->customerFactory->create();
$this->dataObjectHelper->populateWithArray(
$customerDataObject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,26 @@ public function __construct(
* Get allowed customer attributes
*
* @param array $attributeKeys
* @param $addRequiredAttributes
*
* @throws GraphQlInputException
*
* @return AbstractAttribute[]
*/
public function execute($attributeKeys): array
public function execute($attributeKeys, $addRequiredAttributes = false): array
{
/** @var CustomerInterface $customerDataDummy */
$customerDataDummy = $this->customerDataFactory->create();
$requiredDataAttributes = $this->dataObjectProcessor->buildOutputDataArray(
$customerDataDummy,
CustomerInterface::class
);
/**
* Add required attributes for customer entity to passed attribute keys
*/
if ($addRequiredAttributes) {
/** @var CustomerInterface $customerDataDummy */
$customerDataDummy = $this->customerDataFactory->create();
$requiredDataAttributes = $this->dataObjectProcessor->buildOutputDataArray(
$customerDataDummy,
CustomerInterface::class
);
}

$attributeKeys = array_merge($attributeKeys, array_keys($requiredDataAttributes));
$this->searchCriteriaBuilder->addFilter('attribute_code', $attributeKeys, 'in');
$searchCriteria = $this->searchCriteriaBuilder->create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ public function __construct(GetAllowedCustomerAttributes $getAllowedCustomerAttr
* Validate customer data
*
* @param array $customerData
* @param $addRequiredAttributes
*
* @return void
*
* @throws GraphQlInputException
*/
public function execute(array $customerData): void
public function execute(array $customerData, $addRequiredAttributes = false): void
{
$attributes = $this->getAllowedCustomerAttributes->execute(array_keys($customerData));
$attributes = $this->getAllowedCustomerAttributes->execute(array_keys($customerData), $addRequiredAttributes);
$errorInput = [];

foreach ($attributes as $attributeInfo) {
Expand Down

0 comments on commit cc69055

Please sign in to comment.