本文整理汇总了PHP中Magento\Customer\Api\AccountManagementInterface::isEmailAvailable方法的典型用法代码示例。如果您正苦于以下问题:PHP AccountManagementInterface::isEmailAvailable方法的具体用法?PHP AccountManagementInterface::isEmailAvailable怎么用?PHP AccountManagementInterface::isEmailAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Customer\Api\AccountManagementInterface
的用法示例。
在下文中一共展示了AccountManagementInterface::isEmailAvailable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toHtml
/**
* {@inheritdoc}
*/
public function toHtml()
{
if ($this->customerSession->isLoggedIn() || !$this->registration->isAllowed() || !$this->accountManagement->isEmailAvailable($this->getEmailAddress()) || !$this->validateAddresses()) {
return '';
}
return parent::toHtml();
}
示例2: validateEmailAvailable
/**
* Validates that the email address isn't being used by a different account.
*
* @param string $email
* @throws \Magento\Framework\Exception\LocalizedException
* @return void
*/
protected function validateEmailAvailable($email)
{
$websiteId = $this->_storeManager->getStore()->getWebsiteId();
if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email && !$this->customerAccountManagement->isEmailAvailable($email, $websiteId)) {
throw new \Magento\Framework\Exception\LocalizedException(__('This email address is already assigned to another user.'));
}
}
示例3: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->logger->log('Installing customers:');
foreach ($this->fixtures as $file) {
/** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */
$fileName = $this->fixtureHelper->getPath($file);
$csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
foreach ($csvReader as $row) {
// Collect customer profile and addresses data
$customerData['profile'] = $this->convertRowData($row, $this->getDefaultCustomerProfile());
if (!$this->accountManagement->isEmailAvailable($customerData['profile']['email'])) {
continue;
}
$customerData['address'] = $this->convertRowData($row, $this->getDefaultCustomerAddress());
$customerData['address']['region_id'] = $this->getRegionId($customerData['address']);
$address = $customerData['address'];
$regionData = [RegionInterface::REGION_ID => $address['region_id'], RegionInterface::REGION => !empty($address['region']) ? $address['region'] : null, RegionInterface::REGION_CODE => !empty($address['region_code']) ? $address['region_code'] : null];
$region = $this->regionFactory->create();
$this->dataObjectHelper->populateWithArray($region, $regionData, '\\Magento\\Customer\\Api\\Data\\RegionInterface');
$addresses = $this->addressFactory->create();
unset($customerData['address']['region']);
$this->dataObjectHelper->populateWithArray($addresses, $customerData['address'], '\\Magento\\Customer\\Api\\Data\\AddressInterface');
$addresses->setRegion($region)->setIsDefaultBilling(true)->setIsDefaultShipping(true);
$customer = $this->customerFactory->create();
$this->dataObjectHelper->populateWithArray($customer, $customerData['profile'], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$customer->setAddresses([$addresses]);
$this->accountManagement->createAccount($customer, $row['password']);
$this->logger->logInline('.');
}
}
}
示例4: install
/**
* {@inheritdoc}
*/
public function install($fixtures)
{
foreach ($fixtures as $fixture) {
$filePath = $this->fixtureManager->getFixture($fixture);
$rows = $this->csvReader->getData($filePath);
$header = array_shift($rows);
foreach ($rows as $row) {
$data = [];
foreach ($row as $key => $value) {
$data[$header[$key]] = $value;
}
$row = $data;
// Collect customer profile and addresses data
$customerData['profile'] = $this->convertRowData($row, $this->getDefaultCustomerProfile());
if (!$this->accountManagement->isEmailAvailable($customerData['profile']['email'])) {
continue;
}
$customerData['address'] = $this->convertRowData($row, $this->getDefaultCustomerAddress());
$customerData['address']['region_id'] = $this->getRegionId($customerData['address']);
$address = $customerData['address'];
$regionData = [RegionInterface::REGION_ID => $address['region_id'], RegionInterface::REGION => !empty($address['region']) ? $address['region'] : null, RegionInterface::REGION_CODE => !empty($address['region_code']) ? $address['region_code'] : null];
$region = $this->regionFactory->create();
$this->dataObjectHelper->populateWithArray($region, $regionData, '\\Magento\\Customer\\Api\\Data\\RegionInterface');
$addresses = $this->addressFactory->create();
unset($customerData['address']['region']);
$this->dataObjectHelper->populateWithArray($addresses, $customerData['address'], '\\Magento\\Customer\\Api\\Data\\AddressInterface');
$addresses->setRegion($region)->setIsDefaultBilling(true)->setIsDefaultShipping(true);
$customer = $this->customerFactory->create();
$this->dataObjectHelper->populateWithArray($customer, $customerData['profile'], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
$customer->setAddresses([$addresses]);
$this->appState->emulateAreaCode('frontend', [$this->accountManagement, 'createAccount'], [$customer, $row['password']]);
}
}
}
示例5: execute
/**
* @param \Magento\Framework\Event\Observer $observer
* @throws \Exception
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$orderIds = $observer->getEvent()->getData('order_ids');
if (isset($orderIds[0])) {
$order = $this->orderRepository->get($orderIds[0]);
if (!$order->getCustomerId()) {
$isEmailAvailable = $this->accountManagement->isEmailAvailable($order->getCustomerEmail());
//$this->logger->addInfo(print_r($isEmailAvailable,true));
if ($isEmailAvailable) {
try {
$this->orderCustomerService->create($orderIds[0]);
} catch (\Exception $e) {
$this->messageManager->addException($e, $e->getMessage());
throw $e;
}
$this->coreRegistry->register('automatic_account', true);
}
}
}
}
示例6: _customerEmailExists
/**
* Check if customer email exists
*
* @param string $email
* @param int $websiteId
* @return false|\Magento\Customer\Model\Customer
*/
protected function _customerEmailExists($email, $websiteId = null)
{
return !$this->accountManagement->isEmailAvailable($email, $websiteId);
}
示例7: testIsEmailAvailableNonExistentEmail
public function testIsEmailAvailableNonExistentEmail()
{
$this->assertTrue($this->accountManagement->isEmailAvailable('nonexistent@example.com', 1));
}