Ejemplo n.º 1
0
 /**
  * Match provided request and if matched - return corresponding controller
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\Action\Action|null
  */
 public function match(\Magento\Framework\App\RequestInterface $request)
 {
     // if URL has VDE prefix
     if (!$this->_designEditorHelper->isVdeRequest($request)) {
         return null;
     }
     // user must be logged in admin area
     if (!$this->_session->isLoggedIn()) {
         return null;
     }
     // prepare request to imitate
     $this->_prepareVdeRequest($request);
     // apply rewrites
     $this->_urlRewriteService->applyRewrites($request);
     // match routers
     $controller = null;
     $routers = $this->_getMatchedRouters();
     /** @var $router \Magento\Framework\App\RouterInterface */
     foreach ($routers as $router) {
         /** @var $controller \Magento\Framework\App\Action\AbstractAction */
         $controller = $router->match($request);
         if ($controller) {
             $this->_state->update(\Magento\Framework\App\Area::AREA_FRONTEND, $request);
             break;
         }
     }
     // set inline translation mode
     $this->_designEditorHelper->setTranslationMode($request);
     return $controller;
 }
Ejemplo n.º 2
0
 public function testUpdateNavigationMode()
 {
     $this->_setAdditionalExpectations();
     $request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/'));
     $this->_backendSession->expects($this->at(0))->method('setData')->with('vde_current_url', '/');
     $this->_backendSession->expects($this->at(1))->method('setData')->with('vde_current_mode', \Magento\DesignEditor\Model\State::MODE_NAVIGATION);
     $this->_urlModelFactory->expects($this->once())->method('replaceClassName')->with(self::URL_MODEL_NAVIGATION_MODE_CLASS_NAME);
     $this->_areaEmulator->expects($this->once())->method('emulateLayoutArea')->with(self::AREA_CODE);
     $controller = $this->getMock('Magento\\Backend\\App\\Action', [], [], '', false);
     $this->_model->update(self::AREA_CODE, $request, $controller);
 }