/** * Retrieve url of a view file * * @param string $fileId * @param array $params * @return string */ public function getViewFileUrl($fileId, array $params = []) { try { $params = array_merge(['_secure' => $this->_request->isSecure()], $params); return $this->_assetRepo->getUrlWithParams($fileId, $params); } catch (\Magento\Framework\Exception\LocalizedException $e) { return ''; } }
/** * Return the tracking base URL (params are added later) * * @return string */ public function getBaseUrl() { $result = $this->scopeConfig->getValue(self::CONFIG_BASE_URL_XPATH); if (!$result) { $params = ['_secure' => $this->_getRequest()->isSecure()]; return $this->assetRepository->getUrlWithParams("Smile_ElasticsuiteTracker::hit.png", $params); } return $result; }
protected function getLogoUrl($code) { //$params = array_merge(['_secure' => $this->getRequest()->isSecure()], $params); $logo = $this->methods[$code]->getLogo(); if ($logo === false) { return false; } return $this->assetRepo->getUrlWithParams('Wirecard_CheckoutPage::images/' . $logo, ['_secure' => true]); }
/** * Retrieve url of a view file * * @param string $fileId * @param array $params * @return string[] */ protected function getViewFileUrl($fileId, array $params = []) { try { $params = array_merge(['_secure' => $this->request->isSecure()], $params); return $this->assetRepo->getUrlWithParams($fileId, $params); } catch (LocalizedException $e) { $this->logger->critical($e); return $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']); } }
/** * @return void */ public function testGetUrl() { $themeMock = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false); $this->designMock->expects($this->any())->method('getDesignParams')->willReturn(['themeModel' => $themeMock, 'area' => 'area', 'locale' => 'locale']); $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock(); $assetMock->expects($this->any())->method('getUrl')->willReturn('some url'); $this->fileFactoryMock->expects($this->exactly(2))->method('create')->with(['source' => $this->sourceMock, 'context' => '', 'filePath' => 'test/file.js', 'module' => '', 'contentType' => ''])->willReturn($assetMock); $this->assertEquals('some url', $this->repository->getUrl('test/file.js')); $this->assertEquals('some url', $this->repository->getUrlWithParams('test/file.js', [])); }
public function testGetUrlWithParams() { $defaultTheme = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\ThemeInterface'); $defaults = ['area' => 'area', 'themeModel' => $defaultTheme, 'locale' => 'locale']; $this->design->expects($this->atLeastOnce())->method('getDesignParams')->will($this->returnValue($defaults)); $this->design->expects($this->once())->method('getConfigurationDesignTheme')->with('custom_area')->will($this->returnValue(false)); $this->design->expects($this->any())->method('getThemePath')->with($this->theme)->will($this->returnValue('custom_theme')); $this->baseUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://example.com/static/')); $params = ['area' => 'custom_area', 'locale' => 'en_US', 'module' => 'This_Shall_Not_Be_Used']; $result = $this->object->getUrlWithParams('Module_Name::file.ext', $params); $this->assertEquals('http://example.com/static/custom_area/custom_theme/en_US/Module_Name/file.ext', $result); }
/** * Retrieve View URL directive * * @param array $construction * @return string * @see \Magento\Email\Model\Template\Filter::viewDirective() method has been copypasted */ public function viewDirective($construction) { $params = $this->getParameters($construction[2]); $params['_absolute'] = $this->_useAbsoluteLinks; /** * @bug: the "_absolute" key is not supported by underlying services * probably this happened because of multitude of refactorings in past * The original intent of _absolute parameter was to simply append specified path to a base URL * bypassing any kind of processing. * For example, normally you would use {{view url="css/styles.css"}} directive which would automatically resolve * into something like http://example.com/pub/static/area/theme/en_US/css/styles.css * But with _absolute, the expected behavior is this: {{view url="favicon.ico" _absolute=true}} should resolve * into something like http://example.com/favicon.ico * * To fix the issue, it is better not to maintain the _absolute parameter anymore in undrelying services, * but instead just create a different type of directive, for example {{baseUrl path="favicon.ico"}} */ $url = $this->_assetRepo->getUrlWithParams($params['url'], $params); return $url; }
/** * Retrieve url of a view file * * @param string $fileId * @param array $params * @return string */ public function getViewFileUrl($fileId, array $params = []) { try { $params = array_merge(['_secure' => $this->getRequest()->isSecure()], $params); return $this->_assetRepo->getUrlWithParams($fileId, $params); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->_logger->critical($e); return $this->_getNotFoundUrl(); } }
/** * Retrieve View URL directive * * @param string[] $construction * @return string */ public function viewDirective($construction) { $params = $this->_getParameters($construction[2]); $url = $this->_assetRepo->getUrlWithParams($params['url'], $params); return $url; }
/** * Get default email logo image * * @return string */ public function getDefaultEmailLogo() { $designParams = $this->getDesignParams(); return $this->assetRepo->getUrlWithParams(self::DEFAULT_LOGO_FILE_ID, $designParams); }
/** * Get default email logo image * * @return string */ public function getDefaultEmailLogo() { return $this->_assetRepo->getUrlWithParams('Magento_Email::logo_email.gif', array('area' => \Magento\Framework\App\Area::AREA_FRONTEND)); }
/** * Get url to preview image * * @param \Magento\Core\Model\Theme|ThemeInterface $theme * @return string */ public function getPreviewImageUrl(ThemeInterface $theme) { return $theme->isPhysical() ? $this->assetRepo->getUrlWithParams($theme->getPreviewImage(), ['area' => $theme->getData('area'), 'themeModel' => $theme]) : $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . self::PREVIEW_DIRECTORY_PATH . '/' . $theme->getPreviewImage(); }