예제 #1
0
 /**
  * @param string $path
  * @param bool $expected
  * @dataProvider isVdeRequestDataProvider
  */
 public function testIsVdeRequest($path, $expected)
 {
     $this->_model = new \Magento\DesignEditor\Helper\Data($this->_context, self::TEST_FRONT_NAME);
     $requestMock = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $requestMock->expects($this->once())->method('getOriginalPathInfo')->will($this->returnValue($path));
     $this->assertEquals($expected, $this->_model->isVdeRequest($requestMock));
 }
예제 #2
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);
     /**
      * Deprecated line of code was here which should be adopted if needed:
      * $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;
 }
예제 #3
0
파일: Provider.php 프로젝트: aiesh/magento2
 /**
  * Return instance of inline translate class
  *
  * @return \Magento\Framework\Translate\InlineInterface
  */
 public function get()
 {
     return $this->helper->isVdeRequest($this->request) ? $this->vdeInlineTranslate : $this->inlineTranslate;
 }