public function setNewPassword($locale, Customer $customer, $currentPassword, $newPassword) { $client = $this->getClient(); if ($currentPassword == $newPassword) { throw new \InvalidArgumentException('form.type.password'); } if (!empty($currentPassword) && !empty($newPassword)) { $request = CustomerPasswordChangeRequest::ofIdVersionAndPasswords($customer->getId(), $customer->getVersion(), $currentPassword, $newPassword); $response = $request->executeWithClient($client); if ($response->isError()) { throw new \InvalidArgumentException('wrong_password'); } $customer = $request->mapFromResponse($response, $this->getMapper($locale)); return $customer; } return null; }
public static function ofCustomer(Customer $customer) { $userDetails = new static(); $userDetails->setFirstName($customer->getFirstName()); $userDetails->setLastName($customer->getLastName()); $userDetails->setEmail($customer->getEmail()); return $userDetails; }