当前位置: 首页>>代码示例>>PHP>>正文


PHP AccountManagementInterface::isEmailAvailable方法代码示例

本文整理汇总了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();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Registration.php

示例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.'));
     }
 }
开发者ID:nblair,项目名称:magescotch,代码行数:14,代码来源:NewAction.php

示例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('.');
         }
     }
 }
开发者ID:vinai-drive-by-commits,项目名称:magento2-sample-data,代码行数:34,代码来源:Customer.php

示例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']]);
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:37,代码来源:Customer.php

示例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);
             }
         }
     }
 }
开发者ID:sivajik34,项目名称:aac,代码行数:24,代码来源:AutomaticAccountCreateObserver.php

示例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);
 }
开发者ID:nja78,项目名称:magento2,代码行数:11,代码来源:Onepage.php

示例7: testIsEmailAvailableNonExistentEmail

 public function testIsEmailAvailableNonExistentEmail()
 {
     $this->assertTrue($this->accountManagement->isEmailAvailable('nonexistent@example.com', 1));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:4,代码来源:AccountManagementTest.php


注:本文中的Magento\Customer\Api\AccountManagementInterface::isEmailAvailable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。