本文整理汇总了PHP中Magento\Framework\UrlInterface::getBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlInterface::getBaseUrl方法的具体用法?PHP UrlInterface::getBaseUrl怎么用?PHP UrlInterface::getBaseUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\UrlInterface
的用法示例。
在下文中一共展示了UrlInterface::getBaseUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterGetIncludes
/**
* @param PageConfig $subject
* @param string $result
* @return string
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetIncludes(PageConfig $subject, $result)
{
$pattern = '{{MEDIA_URL}}';
if (strpos($result, $pattern) !== false) {
$url = $this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
$result = str_replace($pattern, $url, $result);
}
return $result;
}
示例2: getCommentText
public function getCommentText($elementValue)
{
$url = "";
if ($this->_urlInterface != null) {
$url = $this->_urlInterface->getBaseUrl();
$url = $url . 'signifyd/webhooks/index';
$url = "<a href=\"" . $url . "\">{$url}</a>";
} else {
$url = "{{store url}}/signifyd/webhooks/index";
}
return "{$url} <br />Use this URL to setup your Magento <a href=\"https://app.signifyd.com/settings/notifications\">webhook</a> from the Signifyd console. You MUST setup the webhook to enable order workflows and syncing of guarantees back to Magento.";
}
示例3: getElementHtml
/**
* Return element html code
*
* @return string
*/
public function getElementHtml()
{
$html = '';
if ((string) $this->getValue()) {
$url = $this->_getUrl();
if (!preg_match("/^http\\:\\/\\/|https\\:\\/\\//", $url)) {
$url = $this->_urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]) . $url;
}
$html = '<a href="' . $url . '"' . ' onclick="imagePreview(\'' . $this->getHtmlId() . '_image\'); return false;" ' . $this->_getUiId('link') . '>' . '<img src="' . $url . '" id="' . $this->getHtmlId() . '_image" title="' . $this->getValue() . '"' . ' alt="' . $this->getValue() . '" height="22" width="22" class="small-image-preview v-middle" ' . $this->_getUiId() . ' />' . '</a> ';
}
$this->setClass('input-file');
$html .= parent::getElementHtml();
$html .= $this->_getDeleteCheckbox();
return $html;
}
示例4: addHeadInclude
/**
* Add Link to Head
*
* @return void
*/
protected function addHeadInclude()
{
$styleContent = '';
foreach ($this->moduleList->getNames() as $moduleName) {
$fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/styles.css';
$fileName = $this->fixtureHelper->getPath($fileName);
if (!$fileName) {
continue;
}
$style = file_get_contents($fileName);
$styleContent .= preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', $style);
}
if (empty($styleContent)) {
return;
}
$mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
file_put_contents("{$mediaDir}/styles.css", $styleContent);
$linkTemplate = '<link rel="stylesheet" type="text/css" media="all" href="%sstyles.css" />';
$baseUrl = $this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
$linkText = sprintf($linkTemplate, $baseUrl);
$miscScriptsNode = 'design/head/includes';
$miscScripts = $this->scopeConfig->getValue($miscScriptsNode);
if (!$miscScripts || strpos($miscScripts, $linkText) === false) {
$this->configWriter->save($miscScriptsNode, $miscScripts . $linkText);
$this->configCacheType->clean();
}
}
示例5: getFileContext
/**
* Get a file context value object
*
* Same instance per set of parameters
*
* @param string $baseDirType
* @param string $urlType
* @param string $dirPath
* @return \Magento\Framework\View\Asset\File\Context
*/
private function getFileContext($baseDirType, $urlType, $dirPath)
{
$id = implode('|', array($baseDirType, $urlType, $dirPath));
if (!isset($this->fileContext[$id])) {
$url = $this->baseUrl->getBaseUrl(array('_type' => $urlType));
$this->fileContext[$id] = new \Magento\Framework\View\Asset\File\Context($url, $baseDirType, $dirPath);
}
return $this->fileContext[$id];
}
示例6: getFileContext
/**
* Get a file context value object
*
* Same instance per set of parameters
*
* @param string $baseDirType
* @param string $urlType
* @param string $dirPath
* @return \Magento\Framework\View\Asset\File\Context
*/
private function getFileContext($baseDirType, $urlType, $dirPath)
{
$id = implode('|', [$baseDirType, $urlType, $dirPath]);
if (!isset($this->fileContext[$id])) {
$url = $this->baseUrl->getBaseUrl(['_type' => $urlType]);
$this->fileContext[$id] = $this->contextFactory->create(['baseUrl' => $url, 'baseDirType' => $baseDirType, 'contextPath' => $dirPath]);
}
return $this->fileContext[$id];
}
示例7: aroundExecute
/**
* @return \Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\Result\Redirect|null
*/
public function aroundExecute()
{
$query = $this->request->getParam('q', false);
if (!$query) {
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setUrl($this->url->getBaseUrl());
return $resultRedirect;
}
if ($this->bxHelperData->isAutocompleteEnabled()) {
$responseData = $this->p13nHelper->autocomplete($query, $this->autocompleteHelper);
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($responseData);
return $resultJson;
}
return null;
}
示例8: testGetBaseUrlWithTypeRestoring
/**
* Check that url type is restored to default after call getBaseUrl with type specified in params
*/
public function testGetBaseUrlWithTypeRestoring()
{
/**
* Get base URL with default type
*/
$this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
/**
* Set specified type
*/
$webUrl = $this->_model->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_WEB]);
$this->assertEquals('http://localhost/', $webUrl, 'Incorrect web url');
$this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
/**
* Get url with type specified in params
*/
$mediaUrl = $this->_model->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
$this->assertEquals('http://localhost/pub/media/', $mediaUrl, 'Incorrect media url');
$this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
}
示例9: getStoreMediaUrl
/**
* Retrieve store media url
*
* @param string $fileName
* @return mixed
*/
protected function getStoreMediaUrl($fileName)
{
$fieldConfig = $this->getFieldConfig();
$baseUrl = '';
$urlType = ['_type' => UrlInterface::URL_TYPE_MEDIA];
if (isset($fieldConfig['base_url'])) {
$baseUrl = $fieldConfig['base_url'];
$urlType = ['_type' => empty($baseUrl['type']) ? 'link' : (string) $baseUrl['type']];
$baseUrl = $baseUrl['value'] . '/';
}
return $this->urlBuilder->getBaseUrl($urlType) . $baseUrl . $fileName;
}
示例10: getEnvironmentInformation
/**
* Retrieve environment information of magento
* And installed extensions provided by CedCommerce
*
* @return array
*/
public function getEnvironmentInformation()
{
$info = array();
$info['plateform'] = 'Magento2.x';
$info['domain_name'] = $this->urlBuilder->getBaseUrl();
$info['magento_edition'] = 'default';
if (method_exists('Mage', 'getEdition')) {
$info['magento_edition'] = $this->productMetadata->getEdition();
}
$info['magento_version'] = $this->productMetadata->getVersion();
$info['php_version'] = phpversion();
$info['feed_types'] = $this->_backendConfig->getValue(\Ced\DevTool\Model\Feed::XML_FEED_TYPES);
$info['admin_name'] = $this->_backendConfig->getValue('trans_email/ident_general/name');
if (strlen($info['admin_name']) == 0) {
$info['admin_name'] = $this->_backendConfig->getValue('trans_email/ident_sales/name');
}
$info['admin_email'] = $this->_backendConfig->getValue('trans_email/ident_general/email');
if (strlen($info['admin_email']) == 0) {
$info['admin_email'] = $this->_backendConfig->getValue('trans_email/ident_sales/email');
}
$info['installed_extensions_by_cedcommerce'] = $this->getCedCommerceExtensions(true);
return $info;
}
示例11: buildContext
public function buildContext()
{
return array_merge([self::APP_CONTEXT => 'php', self::APP_NAME => 'Magento Webstore', self::DATA_CENTER => 'external', self::HOST => $this->url->getBaseUrl(), self::LOG_TYPE => 'system', self::RESOURCE => $this->moduleName], $this->getOptionalContext());
}
示例12: getBaseUrl
/**
* get images base url
*
* @return string
*/
public function getBaseUrl()
{
return $this->urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]) . $this->subDir . '/image';
}
示例13: getBaseUrl
/**
* get images base url
*
* @return string
*/
public function getBaseUrl()
{
return $this->urlBuilder->getBaseUrl() . '../pub/' . UrlInterface::URL_TYPE_MEDIA . '/' . $this->subDir . '/image';
}
示例14: fillPropertiesByMinifyingAsset
/**
* Generate minified file and fill the properties to reference that file
*
* @return void
*/
protected function fillPropertiesByMinifyingAsset()
{
$path = $this->originalAsset->getPath();
$this->context = new \Magento\Framework\View\Asset\File\Context($this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_STATIC]), DirectoryList::STATIC_VIEW, self::CACHE_VIEW_REL . '/minified');
$this->filePath = md5($path) . '_' . $this->composeMinifiedName(basename($path));
$this->path = $this->context->getPath() . '/' . $this->filePath;
$this->minify();
$this->file = $this->staticViewDir->getAbsolutePath($this->path);
$this->url = $this->context->getBaseUrl() . $this->path;
}
示例15: getCurrentSecureUrl
/**
* {@inheritdoc}
*
* @param \Magento\Framework\App\RequestInterface $request
* @return string
*/
public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
{
return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
}