customerCollectionFactory = $customerCollectionFactory; parent::__construct($customerFactory, $customerSecureFactory, $customerRegistry, $addressRepository, $customerResourceModel, $customerMetadata, $searchResultsFactory, $eventManager, $storeManager, $extensibleDataObjectConverter, $dataObjectHelper, $imageProcessor, $extensionAttributesJoinProcessor, $collectionProcessor, $notificationStorage, $delegatedStorage, $groupRepository); } /** * @param String $mobile * @param null $websiteId * @return \Magento\Customer\Model\Customer * @throws NoSuchEntityException * @throws \Magento\Framework\Exception\LocalizedException */ protected function getCustomerByMobile(String $mobile, $websiteId = null) { $websiteId = $websiteId?: $this->storeManager->getDefaultStoreView()->getWebsiteId(); /* @var $customer \Magento\Customer\Model\Customer */ $customer = $this->customerCollectionFactory->create() ->addAttributeToSelect('*') ->addAttributeToFilter('mobile', $mobile) ->addAttributeToFilter(CustomerInterface::WEBSITE_ID, $websiteId) ->getFirstItem(); if (!$customer->getId()) { throw new NoSuchEntityException( __( 'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value', [ 'fieldName' => 'mobile', 'fieldValue' => $mobile, 'field2Name' => 'websiteId', 'field2Value' => $websiteId ] ) ); } return $customer; } /** * @param string $email * @param null $websiteId * @return \Magento\Customer\Api\Data\CustomerInterface * @throws NoSuchEntityException * @throws \Magento\Framework\Exception\LocalizedException */ public function get($email, $websiteId = null) { if (preg_match(self::MOBILE_PATTERN, $email)) { return $this->getCustomerByMobile($email, $websiteId)->getDataModel(); } return parent::get($email, $websiteId); } }