/** * 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; }
/** * Retrieve route URL * * @param string $routePath * @param array $routeParams * @return string */ public function getRouteUrl($routePath = null, $routeParams = null) { $this->_hasThemeAndMode(); $url = parent::getRouteUrl($routePath, $routeParams); $baseUrl = trim($this->getBaseUrl(), '/'); $vdeBaseUrl = implode('/', [$baseUrl, $this->_helper->getFrontName(), $this->_mode, $this->_themeId]); if (strpos($url, $baseUrl) === 0 && strpos($url, $vdeBaseUrl) === false) { $url = str_replace($baseUrl, $vdeBaseUrl, $url); } return $url; }
protected function _setAdditionalExpectations() { $this->_dataHelper->expects($this->any())->method('getDisabledCacheTypes')->will($this->returnValue($this->_cacheTypeList)); $this->_cacheStateMock->expects($this->at(0))->method('isEnabled')->with('type1')->will($this->returnValue(true)); $this->_cacheStateMock->expects($this->at(1))->method('setEnabled')->with('type1', false)->will($this->returnSelf()); $this->_cacheStateMock->expects($this->at(2))->method('isEnabled')->with('type2')->will($this->returnValue(true)); $this->_cacheStateMock->expects($this->at(3))->method('setEnabled')->with('type2', false)->will($this->returnSelf()); }
/** * Disable some cache types in VDE mode * * @return void */ protected function _disableCache() { foreach ($this->_dataHelper->getDisabledCacheTypes() as $cacheCode) { if ($this->_cacheState->isEnabled($cacheCode)) { $this->_cacheState->setEnabled($cacheCode, false); } } }
/** * Return URL for ajax requests * * @return string */ protected function _getAjaxUrl() { return $this->_url->getUrl('translation/ajax/index', ['_secure' => $this->_scopeResolver->getScope()->isCurrentlySecure(), \Magento\DesignEditor\Helper\Data::TRANSLATION_MODE => $this->_helper->getTranslationMode()]); }
/** * Return instance of inline translate class * * @return \Magento\Framework\Translate\InlineInterface */ public function get() { return $this->helper->isVdeRequest($this->request) ? $this->vdeInlineTranslate : $this->inlineTranslate; }
public function testGetDisabledCacheTypes() { $this->_model = new \Magento\DesignEditor\Helper\Data($this->_context, self::TEST_FRONT_NAME, ['type1', 'type2']); $this->assertEquals($this->_disabledCacheTypes, $this->_model->getDisabledCacheTypes()); }
/** * @dataProvider textTranslationMode */ public function testTextTranslationMode($mode) { $this->_request->setParam('translation_mode', $mode); $this->_helperData->setTranslationMode($this->_request); $this->assertEquals($mode, $this->_helperData->getTranslationMode()); }
/** * Get url to download CSS file * * @param string $fileId * @param int $themeId * @return string */ public function getDownloadUrl($fileId, $themeId) { return $this->getUrl('adminhtml/system_design_theme/downloadCss', ['theme_id' => $themeId, 'file' => $this->_designEditorHelper->urlEncode($fileId)]); }