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


PHP Session::getId方法代碼示例

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


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

示例1: execute

 /**
  * Customer logout action
  *
  * @return \Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     $lastCustomerId = $this->session->getId();
     $this->session->logout()->setBeforeAuthUrl($this->_redirect->getRefererUrl())->setLastCustomerId($lastCustomerId);
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath('*/*/logoutSuccess');
     return $resultRedirect;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:Logout.php

示例2: execute

 /**
  * Customer logout action
  *
  * @return \Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     $lastCustomerId = $this->session->getId();
     $this->session->logout()->setBeforeAuthUrl($this->_redirect->getRefererUrl())->setLastCustomerId($lastCustomerId);
     if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
         $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
         $metadata->setPath('/');
         $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
     }
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath('*/*/logoutSuccess');
     return $resultRedirect;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:19,代碼來源:Logout.php

示例3: getWishlist

 /**
  * @return Collection
  */
 public function getWishlist()
 {
     if (!$this->_wishlist) {
         $this->_wishlist = $this->_createWishList()->loadByCustomerId($this->_customerSession->getId());
         $this->_wishlist->getItemCollection()->addAttributeToSelect('name')->addAttributeToSelect('price')->addAttributeToSelect('small_image')->addAttributeToFilter('store_id', ['in' => $this->_wishlist->getSharedStoreIds()])->addAttributeToSort('added_at', 'desc')->setCurPage(1)->setPageSize(3)->load();
     }
     return $this->_wishlist->getItemCollection();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:11,代碼來源:Sidebar.php

示例4: _construct

 /**
  * @return void
  */
 protected function _construct()
 {
     /*
      * setting cache to save the rss for 10 minutes
      */
     $this->setCacheKey('rss_catalog_category_' . $this->getRequest()->getParam('cid') . '_' . $this->getRequest()->getParam('store_id') . '_' . $this->customerSession->getId());
     $this->setCacheLifetime(600);
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:11,代碼來源:Category.php

示例5: _initPayment

 /**
  * Instantiate current payment and put it into registry
  *
  * @return \Magento\RecurringPayment\Model\Payment
  * @throws \Magento\Framework\Model\Exception
  */
 protected function _initPayment()
 {
     $payment = $this->_objectManager->create('Magento\\RecurringPayment\\Model\\Payment')->load($this->getRequest()->getParam('payment'));
     if (!$payment->getId() || $payment->getCustomerId() != $this->_customerSession->getId()) {
         throw new \Magento\Framework\Model\Exception(__('We can\'t find the payment you specified.'));
     }
     $this->_coreRegistry->register('current_recurring_payment', $payment);
     return $payment;
 }
開發者ID:Atlis,項目名稱:docker-magento2,代碼行數:15,代碼來源:RecurringPayment.php

示例6: 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

示例7: _construct

 /**
  * @return void
  */
 protected function _construct()
 {
     $this->setCacheKey('rss_catalog_category_' . $this->getRequest()->getParam('cid') . '_' . $this->getStoreId() . '_' . $this->customerSession->getId());
     parent::_construct();
 }
開發者ID:tingyeeh,項目名稱:magento2,代碼行數:8,代碼來源:Category.php

示例8: getCustomerId

 /**
  * Returns customer id from session
  *
  * @return int|null
  */
 public function getCustomerId()
 {
     return $this->customerSession->getId();
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:9,代碼來源:CurrentCustomer.php


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