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


PHP AccountManagementInterface::getConfirmationStatus方法代码示例

本文整理汇总了PHP中Magento\Customer\Api\AccountManagementInterface::getConfirmationStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP AccountManagementInterface::getConfirmationStatus方法的具体用法?PHP AccountManagementInterface::getConfirmationStatus怎么用?PHP AccountManagementInterface::getConfirmationStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Customer\Api\AccountManagementInterface的用法示例。


在下文中一共展示了AccountManagementInterface::getConfirmationStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _addEditCustomerFormFields

 /**
  * Edit/View Existing Customer form fields
  *
  * @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
  * @return string[] Values to set on the form
  */
 protected function _addEditCustomerFormFields($fieldset)
 {
     $fieldset->getForm()->getElement('created_in')->setDisabled('disabled');
     $fieldset->getForm()->getElement('website_id')->setDisabled('disabled');
     $customerData = $this->_getCustomerDataObject();
     if ($customerData->getId() && $this->_accountManagement->isReadonly($customerData->getId())) {
         return [];
     }
     // Prepare customer confirmation control (only for existing customers)
     $confirmationStatus = $this->_accountManagement->getConfirmationStatus($customerData->getId());
     $confirmationKey = $customerData->getConfirmation();
     if ($confirmationStatus != AccountManagementInterface::ACCOUNT_CONFIRMED) {
         $confirmationAttr = $this->_customerMetadata->getAttributeMetadata('confirmation');
         if (!$confirmationKey) {
             $confirmationKey = $this->_getRandomConfirmationKey();
         }
         $element = $fieldset->addField('confirmation', 'select', ['name' => 'confirmation', 'label' => __($confirmationAttr->getFrontendLabel())]);
         $element->setEntityAttribute($confirmationAttr);
         $element->setValues(['' => 'Confirmed', $confirmationKey => 'Not confirmed']);
         // Prepare send welcome email checkbox if customer is not confirmed
         // no need to add it, if website ID is empty
         if ($customerData->getConfirmation() && $customerData->getWebsiteId()) {
             $fieldset->addField('sendemail', 'checkbox', ['name' => 'sendemail', 'label' => __('Send Welcome Email after Confirmation')]);
             return ['sendemail' => '1'];
         }
     }
     return [];
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:Account.php

示例2: getIsConfirmedStatus

 /**
  * Check if account is confirmed
  *
  * @return \Magento\Framework\Phrase
  */
 public function getIsConfirmedStatus()
 {
     $id = $this->getCustomerId();
     switch ($this->accountManagement->getConfirmationStatus($id)) {
         case AccountManagementInterface::ACCOUNT_CONFIRMED:
             return __('Confirmed');
         case AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED:
             return __('Confirmation Required');
         case AccountManagementInterface::ACCOUNT_CONFIRMATION_NOT_REQUIRED:
             return __('Confirmation Not Required');
     }
     return __('Indeterminate');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:PersonalInfo.php

示例3: _involveNewCustomer

 /**
  * Involve new customer to system
  *
  * @return $this
  */
 protected function _involveNewCustomer()
 {
     $customer = $this->getQuote()->getCustomer();
     $confirmationStatus = $this->accountManagement->getConfirmationStatus($customer->getId());
     if ($confirmationStatus === \Magento\Customer\Model\AccountManagement::ACCOUNT_CONFIRMATION_REQUIRED) {
         $url = $this->_customerUrl->getEmailConfirmationUrl($customer->getEmail());
         $this->messageManager->addSuccess(__('You must confirm your account. Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.', $url));
     } else {
         $this->getCustomerSession()->loginById($customer->getId());
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:17,代码来源:Onepage.php

示例4: execute

 /**
  * Create customer account action
  *
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute()
 {
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     if ($this->session->isLoggedIn() || !$this->registration->isAllowed()) {
         $resultRedirect->setPath('*/*/');
         return $resultRedirect;
     }
     if (!$this->getRequest()->isPost()) {
         $url = $this->urlModel->getUrl('*/*/create', ['_secure' => true]);
         $resultRedirect->setUrl($this->_redirect->error($url));
         return $resultRedirect;
     }
     $this->session->regenerateId();
     try {
         $address = $this->extractAddress();
         $addresses = $address === null ? [] : [$address];
         $customer = $this->customerExtractor->extract('customer_account_create', $this->_request);
         $customer->setAddresses($addresses);
         $password = $this->getRequest()->getParam('password');
         $confirmation = $this->getRequest()->getParam('password_confirmation');
         $redirectUrl = $this->session->getBeforeAuthUrl();
         $this->checkPasswordConfirmation($password, $confirmation);
         $customer = $this->accountManagement->createAccount($customer, $password, $redirectUrl);
         if ($this->getRequest()->getParam('is_subscribed', false)) {
             $this->subscriberFactory->create()->subscribeCustomerById($customer->getId());
         }
         $this->_eventManager->dispatch('customer_register_success', ['account_controller' => $this, 'customer' => $customer]);
         $confirmationStatus = $this->accountManagement->getConfirmationStatus($customer->getId());
         if ($confirmationStatus === AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED) {
             $email = $this->customerUrl->getEmailConfirmationUrl($customer->getEmail());
             // @codingStandardsIgnoreStart
             $this->messageManager->addSuccess(__('You must confirm your account. Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.', $email));
             // @codingStandardsIgnoreEnd
             $url = $this->urlModel->getUrl('*/*/index', ['_secure' => true]);
             $resultRedirect->setUrl($this->_redirect->success($url));
         } else {
             $this->session->setCustomerDataAsLoggedIn($customer);
             $this->messageManager->addSuccess($this->getSuccessMessage());
             $resultRedirect = $this->accountRedirect->getRedirect();
         }
         return $resultRedirect;
     } catch (StateException $e) {
         $url = $this->urlModel->getUrl('customer/account/forgotpassword');
         // @codingStandardsIgnoreStart
         $message = __('There is already an account with this email address. If you are sure that it is your email address, <a href="%1">click here</a> to get your password and access your account.', $url);
         // @codingStandardsIgnoreEnd
         $this->messageManager->addError($message);
     } catch (InputException $e) {
         $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage()));
         foreach ($e->getErrors() as $error) {
             $this->messageManager->addError($this->escaper->escapeHtml($error->getMessage()));
         }
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('We can\'t save the customer.'));
     }
     $this->session->setCustomerFormData($this->getRequest()->getPostValue());
     $defaultUrl = $this->urlModel->getUrl('*/*/create', ['_secure' => true]);
     $resultRedirect->setUrl($this->_redirect->error($defaultUrl));
     return $resultRedirect;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:67,代码来源:CreatePost.php

示例5: _updateCustomerSubscription

 /**
  * Saving customer subscription status
  *
  * @param int $customerId
  * @param bool $subscribe indicates whether the customer should be subscribed or unsubscribed
  * @return  $this
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _updateCustomerSubscription($customerId, $subscribe)
 {
     try {
         $customerData = $this->customerRepository->getById($customerId);
     } catch (NoSuchEntityException $e) {
         return $this;
     }
     $this->loadByCustomerId($customerId);
     if (!$subscribe && !$this->getId()) {
         return $this;
     }
     if (!$this->getId()) {
         $this->setSubscriberConfirmCode($this->randomSequence());
     }
     $sendInformationEmail = false;
     $status = self::STATUS_SUBSCRIBED;
     if ($subscribe) {
         if (AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED == $this->customerAccountManagement->getConfirmationStatus($customerId)) {
             $status = self::STATUS_UNCONFIRMED;
         }
     } else {
         $status = self::STATUS_UNSUBSCRIBED;
     }
     /**
      * If subscription status has been changed then send email to the customer
      */
     if ($status != self::STATUS_UNCONFIRMED && $status != $this->getStatus()) {
         $sendInformationEmail = true;
     }
     if ($status != $this->getStatus()) {
         $this->setStatusChanged(true);
     }
     $this->setStatus($status);
     if (!$this->getId()) {
         $storeId = $customerData->getStoreId();
         if ($customerData->getStoreId() == 0) {
             $storeId = $this->_storeManager->getWebsite($customerData->getWebsiteId())->getDefaultStore()->getId();
         }
         $this->setStoreId($storeId)->setCustomerId($customerData->getId())->setEmail($customerData->getEmail());
     } else {
         $this->setStoreId($customerData->getStoreId())->setEmail($customerData->getEmail());
     }
     $this->save();
     $sendSubscription = $sendInformationEmail;
     if ($sendSubscription === null xor $sendSubscription) {
         try {
             if ($this->isStatusChanged() && $status == self::STATUS_UNSUBSCRIBED) {
                 $this->sendUnsubscriptionEmail();
             } elseif ($this->isStatusChanged() && $status == self::STATUS_SUBSCRIBED) {
                 $this->sendConfirmationSuccessEmail();
             }
         } catch (MailException $e) {
             // If we are not able to send a new account email, this should be ignored
             $this->_logger->critical($e);
         }
     }
     return $this;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:68,代码来源:Subscriber.php


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