Exemple #1
0
 /**
  * Dispatch request
  *
  * @param RequestInterface $request
  * @return ResponseInterface
  * @throws NotFoundException
  */
 public function dispatch(RequestInterface $request)
 {
     $this->_request = $request;
     $profilerKey = 'CONTROLLER_ACTION:' . $request->getFullActionName();
     $eventParameters = ['controller_action' => $this, 'request' => $request];
     $this->_eventManager->dispatch('controller_action_predispatch', $eventParameters);
     $this->_eventManager->dispatch('controller_action_predispatch_' . $request->getRouteName(), $eventParameters);
     $this->_eventManager->dispatch('controller_action_predispatch_' . $request->getFullActionName(), $eventParameters);
     \Magento\Framework\Profiler::start($profilerKey);
     $result = null;
     if ($request->isDispatched() && !$this->_actionFlag->get('', self::FLAG_NO_DISPATCH)) {
         \Magento\Framework\Profiler::start('action_body');
         $result = $this->execute();
         \Magento\Framework\Profiler::start('postdispatch');
         if (!$this->_actionFlag->get('', self::FLAG_NO_POST_DISPATCH)) {
             $this->_eventManager->dispatch('controller_action_postdispatch_' . $request->getFullActionName(), $eventParameters);
             $this->_eventManager->dispatch('controller_action_postdispatch_' . $request->getRouteName(), $eventParameters);
             $this->_eventManager->dispatch('controller_action_postdispatch', $eventParameters);
         }
         \Magento\Framework\Profiler::stop('postdispatch');
         \Magento\Framework\Profiler::stop('action_body');
     }
     \Magento\Framework\Profiler::stop($profilerKey);
     return $result ?: $this->_response;
 }
Exemple #2
0
 /**
  * Check customer authentication
  *
  * @param RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$request->isDispatched()) {
         return parent::dispatch($request);
     }
     if (!$this->_getSession()->authenticate($this)) {
         $this->_actionFlag->set('', 'no-dispatch', true);
     }
     return parent::dispatch($request);
 }
 /**
  * Make sure customer is logged in and put it into registry
  *
  * @param RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$request->isDispatched()) {
         return parent::dispatch($request);
     }
     if (!$this->_customerSession->authenticate($this)) {
         $this->_actionFlag->set('', 'no-dispatch', true);
     }
     $customer = $this->_customerSession->getCustomer();
     $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER, $customer);
     $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customer->getId());
     return parent::dispatch($request);
 }
Exemple #4
0
 /**
  * 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);
 }