/** * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer * * @throws \Spryker\Zed\Customer\Business\Exception\CustomerNotFoundException * * @return \Orm\Zed\Customer\Persistence\SpyCustomer */ protected function getCustomerFromCustomerTransfer(CustomerTransfer $customerTransfer) { $customer = null; if ($customerTransfer->getEmail()) { $customer = $this->queryContainer->queryCustomerByEmail($customerTransfer->getEmail())->findOne(); } elseif ($customerTransfer->getIdCustomer()) { $customer = $this->queryContainer->queryCustomerById($customerTransfer->getIdCustomer())->findOne(); } if ($customer === null) { throw new CustomerNotFoundException(sprintf('Customer not found for email `%s` or ID `%s`.', $customerTransfer->getEmail(), $customerTransfer->getIdCustomer())); } return $customer; }
/** * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer * * @return bool */ protected function hasCustomer(CustomerTransfer $customerTransfer) { $result = false; $customerEntity = null; if ($customerTransfer->getIdCustomer()) { $customerEntity = $this->queryContainer->queryCustomerById($customerTransfer->getIdCustomer())->findOne(); } elseif ($customerTransfer->getEmail()) { $customerEntity = $this->queryContainer->queryCustomerByEmail($customerTransfer->getEmail())->findOne(); } if ($customerEntity !== null) { $result = true; } return $result; }