當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session::getCustomerData方法代碼示例

本文整理匯總了PHP中Magento\Customer\Model\Session::getCustomerData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::getCustomerData方法的具體用法?PHP Session::getCustomerData怎麽用?PHP Session::getCustomerData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Customer\Model\Session的用法示例。


在下文中一共展示了Session::getCustomerData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getConfig

 /**
  * Set configuration for AdyenHPP payemnt method
  *
  * @return array
  */
 public function getConfig()
 {
     // set to active
     $config = ['payment' => [self::CODE => ['isActive' => true, 'redirectUrl' => $this->_urlBuilder->getUrl('adyen/process/redirect', ['_secure' => $this->_getRequest()->isSecure()])]]];
     // get customer
     if ($this->_customerSession->isLoggedIn()) {
         $gender = \Adyen\Payment\Model\Gender::getAdyenGenderFromMagentoGender($this->_customerSession->getCustomerData()->getGender());
         // format to calendar date
         $dob = $this->_customerSession->getCustomerData()->getDob();
         $dob = strtotime($dob);
         $dob = date('m/d/Y', $dob);
     } else {
         $gender = "";
         $dob = "";
     }
     // add to config
     $config['payment']['adyenHpp']['gender'] = $gender;
     $config['payment']['adyenHpp']['dob'] = $dob;
     // gender types
     $config['payment']['adyenHpp']['genderTypes'] = \Adyen\Payment\Model\Gender::getGenderTypes();
     $paymentMethodSelectionOnAdyen = $this->_adyenHelper->getAdyenHppConfigDataFlag('payment_selection_on_adyen');
     $config['payment']['adyenHpp']['isPaymentMethodSelectionOnAdyen'] = $paymentMethodSelectionOnAdyen;
     $config['payment']['adyenHpp']['showGender'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_gender');
     $config['payment']['adyenHpp']['showDob'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_dob');
     $config['payment']['adyenHpp']['showTelephone'] = $this->_adyenHelper->getAdyenHppConfigDataFlag('show_telephone');
     return $config;
 }
開發者ID:Adyen,項目名稱:adyen-magento2,代碼行數:32,代碼來源:AdyenHppConfigProvider.php

示例2: getFacebookUser

 /**
  * Get facebook user
  *
  * @return array|null
  */
 public function getFacebookUser()
 {
     $facebookUser = null;
     $customer = $this->customerSession->getCustomerData();
     $accessTokenAttribute = $customer->getCustomAttribute('sf_access_token');
     if ($accessTokenAttribute) {
         /** @var $accessToken \Facebook\Authentication\AccessToken */
         $accessToken = unserialize($accessTokenAttribute->getValue());
         try {
             $facebookUser = $this->facebook->get('/me?fields=' . static::FIELDS, $accessToken)->getGraphUser()->all();
         } catch (FacebookSDKException $e) {
             $this->logger->addError($e->getMessage());
         } catch (\Exception $e) {
             $this->logger->addError($e->getMessage());
         }
     }
     return $facebookUser;
 }
開發者ID:Viktor-V,項目名稱:Facebook-Login,代碼行數:23,代碼來源:Account.php

示例3: execute

 /**
  * Dispatch request
  *
  * @return ResponseInterface
  */
 public function execute()
 {
     $customer = $this->customerSession->getCustomerData();
     $accessTokenAttribute = $customer->getCustomAttribute('sf_access_token');
     $facebookUserIdAttribute = $customer->getCustomAttribute('sf_access_token');
     if ($accessTokenAttribute && $facebookUserIdAttribute) {
         /** @var $accessToken \Facebook\Authentication\AccessToken */
         $accessToken = unserialize($accessTokenAttribute->getValue());
         $facebookUserId = $facebookUserIdAttribute->getValue();
         try {
             $this->facebook->delete('/' . $facebookUserId . '/permissions', [], $accessToken);
             $customer->setCustomAttribute('sf_id', null);
             $customer->setCustomAttribute('sf_access_token', null);
             $this->customerRepository->save($customer);
             $this->messageManager->addSuccess(__('You have successfully disconnected your Facebook account from our store account.'));
         } catch (Exception $e) {
             $this->logger->addError($e->getMessage());
             $this->messageManager->addError(__("Oops. Something went wrong! Please try again later."));
         }
     }
     return $this->_redirect($this->_redirect->getRefererUrl());
 }
開發者ID:Viktor-V,項目名稱:Facebook-Login,代碼行數:27,代碼來源:Disconnect.php

示例4: execute

 /**
  * Dispatch request
  *
  * @return ResponseInterface
  */
 public function execute()
 {
     $facebookHelper = $this->facebook->getRedirectLoginHelper();
     try {
         $accessToken = $facebookHelper->getAccessToken();
         if (isset($accessToken)) {
             $facebookUser = $this->facebook->get('/me?fields=' . static::FIELDS, $accessToken)->getGraphUser();
             $customer = $this->customerRepository->getByFacebookId($facebookUser->getId());
             if ($this->customerSession->getId()) {
                 $this->customer = $this->customerSession->getCustomerData();
                 $this->createOrUpdateAndLogin($facebookUser, $accessToken);
                 $this->messageManager->addSuccess(__("Your Facebook account is now connected to your account at our store."));
             } else {
                 if (!is_null($customer)) {
                     $this->customer = $customer;
                     $this->createOrUpdateAndLogin($facebookUser, $accessToken);
                     $this->messageManager->addSuccess(__("You have successfully logged in using your Facebook account."));
                 } else {
                     try {
                         $this->customer = $this->customerRepository->get($facebookUser->getEmail());
                     } finally {
                         $customer = $this->createOrUpdateAndLogin($facebookUser, $accessToken);
                         if ($this->customer->getId() == $customer->getId()) {
                             $this->messageManager->addSuccess(__("We have discovered you already have an account at our store." . " Your Facebook account is now connected to your store account."));
                         } else {
                             $this->messageManager->addSuccess(__("Your Facebook account is now connected to your new user account at our store."));
                         }
                     }
                 }
             }
         } else {
             throw new FacebookSDKException('The Facebook code is null');
         }
     } catch (FacebookSDKException $e) {
         $this->logger->addError($e->getMessage());
         $this->messageManager->addError(__("Oops. Something went wrong! Please try again later."));
     } catch (InputException $e) {
         $this->logger->addError($e->getMessage());
         $this->messageManager->addError(__("Some of required values is not received. Please, check your Facebook settings." . "Required fields: email, first name, last name."));
     } catch (Exception $e) {
         $this->logger->addError($e->getMessage());
         $this->messageManager->addError(__("Oops. Something went wrong! Please try again later."));
     }
     $this->_redirect($this->_redirect->getRefererUrl());
 }
開發者ID:Viktor-V,項目名稱:Facebook-Login,代碼行數:50,代碼來源:Index.php


注:本文中的Magento\Customer\Model\Session::getCustomerData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。