Example #1
0
 /**
  * Perform customer authentication and wishlist feature state checks
  *
  * @param \Magento\Framework\App\ActionInterface $subject
  * @param RequestInterface $request
  * @return void
  * @throws \Magento\Framework\Exception\NotFoundException
  */
 public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, RequestInterface $request)
 {
     if ($this->authenticationState->isEnabled() && !$this->customerSession->authenticate()) {
         $subject->getActionFlag()->set('', 'no-dispatch', true);
         if (!$this->customerSession->getBeforeWishlistUrl()) {
             $this->customerSession->setBeforeWishlistUrl($this->redirector->getRefererUrl());
         }
         $this->customerSession->setBeforeWishlistRequest($request->getParams());
         $this->customerSession->setBeforeRequestParams($this->customerSession->getBeforeWishlistRequest());
         $this->customerSession->setBeforeModuleName('wishlist');
         $this->customerSession->setBeforeControllerName('index');
         $this->customerSession->setBeforeAction('add');
     }
     if (!$this->config->isSetFlag('wishlist/general/active')) {
         throw new NotFoundException(__('Page not found.'));
     }
 }