Ejemplo n.º 1
0
 /**
  * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
  *
  * @throws \Spryker\Zed\Customer\Business\Exception\CustomerNotFoundException
  *
  * @return \Orm\Zed\Customer\Persistence\SpyCustomer
  */
 protected function getCustomer(CustomerTransfer $customerTransfer)
 {
     $customerEntity = null;
     if ($customerTransfer->getIdCustomer()) {
         $customerEntity = $this->queryContainer->queryCustomerById($customerTransfer->getIdCustomer())->findOne();
     } elseif ($customerTransfer->getEmail()) {
         $customerEntity = $this->queryContainer->queryCustomerByEmail($customerTransfer->getEmail())->findOne();
     } elseif ($customerTransfer->getRestorePasswordKey()) {
         $customerEntity = $this->queryContainer->queryCustomerByRestorePasswordKey($customerTransfer->getRestorePasswordKey())->findOne();
     }
     if ($customerEntity !== null) {
         return $customerEntity;
     }
     throw new CustomerNotFoundException(sprintf('Customer not found by either ID `%s`, email `%s` or restore password key `%s`.', $customerTransfer->getIdCustomer(), $customerTransfer->getEmail(), $customerTransfer->getRestorePasswordKey()));
 }