本文整理匯總了PHP中Magento\Customer\Model\Session::setBeforeAuthUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::setBeforeAuthUrl方法的具體用法?PHP Session::setBeforeAuthUrl怎麽用?PHP Session::setBeforeAuthUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Customer\Model\Session
的用法示例。
在下文中一共展示了Session::setBeforeAuthUrl方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: redirectLogin
/**
* Performs redirect to login for checkout
* @param RedirectLoginInterface $expressRedirect
* @param string|null $customerBeforeAuthUrlDefault
* @return void
*/
public function redirectLogin(RedirectLoginInterface $expressRedirect, $customerBeforeAuthUrlDefault = null)
{
$this->_actionFlag->set('', 'no-dispatch', true);
foreach ($expressRedirect->getActionFlagList() as $actionKey => $actionFlag) {
$this->_actionFlag->set('', $actionKey, $actionFlag);
}
$expressRedirect->getResponse()->setRedirect($this->_objectManager->get('Magento\\Framework\\Url\\Helper\\Data')->addRequestParam($expressRedirect->getLoginUrl(), ['context' => 'checkout']));
$customerBeforeAuthUrl = $customerBeforeAuthUrlDefault;
if ($expressRedirect->getCustomerBeforeAuthUrl()) {
$customerBeforeAuthUrl = $expressRedirect->getCustomerBeforeAuthUrl();
}
if ($customerBeforeAuthUrl) {
$this->_customerSession->setBeforeAuthUrl($customerBeforeAuthUrl);
}
}
示例2: dispatch
/**
* Dispatch request
*
* @param RequestInterface $request
* @return \Magento\Framework\App\ResponseInterface
*/
public function dispatch(RequestInterface $request)
{
$allowGuest = $this->_objectManager->get('Magento\\Review\\Helper\\Data')->getIsGuestAllowToWrite();
if (!$request->isDispatched()) {
return parent::dispatch($request);
}
if (!$allowGuest && $request->getActionName() == 'post' && $request->isPost()) {
if (!$this->_customerSession->isLoggedIn()) {
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
$this->_customerSession->setBeforeAuthUrl($this->_url->getUrl('*/*/*', ['_current' => true]));
$this->_reviewSession->setFormData($request->getPostValue())->setRedirectUrl($this->_redirect->getRefererUrl());
$this->getResponse()->setRedirect($this->_objectManager->get('Magento\\Customer\\Model\\Url')->getLoginUrl());
}
}
return parent::dispatch($request);
}
示例3: redirectLogin
/**
* Redirect to login page
*
* @return void
*/
public function redirectLogin()
{
$this->_actionFlag->set('', 'no-dispatch', true);
$this->_customerSession->setBeforeAuthUrl($this->_redirect->getRefererUrl());
$this->getResponse()->setRedirect($this->_urlHelper->addRequestParam($this->_customerUrl->getLoginUrl(), ['context' => 'checkout']));
}