本文整理汇总了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']));
}