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


PHP AccountManagementInterface::getPasswordHash方法代码示例

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


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

示例1: testCustomerCreated

 /**
  * @magentoAppArea adminhtml
  * @magentoDataFixture Magento/Newsletter/_files/subscribers.php
  */
 public function testCustomerCreated()
 {
     $objectManager = Bootstrap::getObjectManager();
     /** @var \Magento\Newsletter\Model\Subscriber $subscriber */
     $subscriber = $objectManager->create('Magento\\Newsletter\\Model\\Subscriber');
     $subscriber->loadByEmail('customer_two@example.com');
     $this->assertTrue($subscriber->isSubscribed());
     $this->assertEquals(0, (int) $subscriber->getCustomerId());
     /** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory */
     $customerFactory = $objectManager->get('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory');
     $customerDataObject = $customerFactory->create()->setFirstname('Firstname')->setLastname('Lastname')->setEmail('customer_two@example.com');
     $createdCustomer = $this->customerRepository->save($customerDataObject, $this->accountManagement->getPasswordHash('password'));
     $subscriber->loadByEmail('customer_two@example.com');
     $this->assertTrue($subscriber->isSubscribed());
     $this->assertEquals((int) $createdCustomer->getId(), (int) $subscriber->getCustomerId());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:20,代码来源:PluginTest.php

示例2: createQuote

 /**
  * Create a quote object with customer
  *
  * @param array $quoteData
  * @param \Magento\Customer\Api\Data\CustomerInterface $customer
  * @return \Magento\Quote\Model\Quote
  */
 protected function createQuote($quoteData, $customer)
 {
     /** @var \Magento\Customer\Api\AddressRepositoryInterface $addressService */
     $addressService = $this->objectManager->create('Magento\\Customer\\Api\\AddressRepositoryInterface');
     /** @var array $shippingAddressOverride */
     $shippingAddressOverride = empty($quoteData['shipping_address']) ? [] : $quoteData['shipping_address'];
     /** @var  \Magento\Customer\Model\Address $shippingAddress */
     $shippingAddress = $this->createCustomerAddress($shippingAddressOverride, $customer->getId());
     /** @var \Magento\Quote\Model\Quote\Address $quoteShippingAddress */
     $quoteShippingAddress = $this->objectManager->create('Magento\\Quote\\Model\\Quote\\Address');
     $quoteShippingAddress->importCustomerAddressData($addressService->getById($shippingAddress->getId()));
     /** @var array $billingAddressOverride */
     $billingAddressOverride = empty($quoteData['billing_address']) ? [] : $quoteData['billing_address'];
     /** @var  \Magento\Customer\Model\Address $billingAddress */
     $billingAddress = $this->createCustomerAddress($billingAddressOverride, $customer->getId());
     /** @var \Magento\Quote\Model\Quote\Address $quoteBillingAddress */
     $quoteBillingAddress = $this->objectManager->create('Magento\\Quote\\Model\\Quote\\Address');
     $quoteBillingAddress->importCustomerAddressData($addressService->getById($billingAddress->getId()));
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->objectManager->create('Magento\\Quote\\Model\\Quote');
     $quote->setStoreId(1)->setIsActive(true)->setIsMultiShipping(false)->assignCustomerWithAddressChange($customer, $quoteBillingAddress, $quoteShippingAddress)->setCheckoutMethod('register')->setPasswordHash($this->accountManagement->getPasswordHash(static::CUSTOMER_PASSWORD));
     return $quote;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:30,代码来源:SetupUtil.php

示例3: _validateCustomerData

 /**
  * Validate customer data and set some its data for further usage in quote
  *
  * Will return either true or array with error messages
  *
  * @param array $data
  * @return bool|array
  */
 protected function _validateCustomerData(array $data)
 {
     $quote = $this->getQuote();
     $isCustomerNew = !$quote->getCustomerId();
     $customer = $quote->getCustomer();
     $customerData = $this->extensibleDataObjectConverter->toFlatArray($customer, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     /** @var Form $customerForm */
     $customerForm = $this->_formFactory->create(\Magento\Customer\Api\CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, 'checkout_register', $customerData, $this->_request->isAjax(), Form::IGNORE_INVISIBLE, []);
     if ($isCustomerNew) {
         $customerRequest = $customerForm->prepareRequest($data);
         $customerData = $customerForm->extractData($customerRequest);
     }
     $customerErrors = $customerForm->validateData($customerData);
     if ($customerErrors !== true) {
         return ['error' => -1, 'message' => implode(', ', $customerErrors)];
     }
     if (!$isCustomerNew) {
         return true;
     }
     $customer = $this->customerDataFactory->create();
     $this->dataObjectHelper->populateWithArray($customer, $customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
         // We always have $customerRequest here, otherwise we would have been kicked off the function several
         // lines above
         $password = $customerRequest->getParam('customer_password');
         if ($password != $customerRequest->getParam('confirm_password')) {
             return ['error' => -1, 'message' => __('Password and password confirmation are not equal.')];
         }
         $quote->setPasswordHash($this->accountManagement->getPasswordHash($password));
     } else {
         // set NOT LOGGED IN group id explicitly,
         // otherwise copyFieldsetToTarget('customer_account', 'to_quote') will fill it with default group id value
         $customer->setGroupId(GroupInterface::NOT_LOGGED_IN_ID);
     }
     //validate customer
     $result = $this->accountManagement->validate($customer);
     if (!$result->isValid()) {
         return ['error' => -1, 'message' => implode(', ', $result->getMessages())];
     }
     // copy customer/guest email to address
     $quote->getBillingAddress()->setEmail($customer->getEmail());
     // copy customer data to quote
     $this->_objectCopyService->copyFieldsetToTarget('customer_account', 'to_quote', $this->extensibleDataObjectConverter->toFlatArray($customer, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface'), $quote);
     return true;
 }
开发者ID:nja78,项目名称:magento2,代码行数:53,代码来源:Onepage.php


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