当前位置: 首页>>代码示例>>PHP>>正文


PHP Repository::getUrl方法代码示例

本文整理汇总了PHP中Magento\Framework\View\Asset\Repository::getUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::getUrl方法的具体用法?PHP Repository::getUrl怎么用?PHP Repository::getUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\View\Asset\Repository的用法示例。


在下文中一共展示了Repository::getUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetUrl

 public function testGetUrl()
 {
     $this->mockDesign();
     $this->baseUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://example.com/static/'));
     $result = $this->object->getUrl('Module_Name::img/product/placeholder.png');
     $this->assertEquals('http://example.com/static/area/theme/locale/Module_Name/img/product/placeholder.png', $result);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:7,代码来源:RepositoryTest.php

示例2: getElementHtml

    /**
     * Return element html code
     *
     * @return string
     */
    public function getElementHtml()
    {
        $htmlId = $this->_escaper->escapeHtml($this->getHtmlId());
        $uploadUrl = $this->_escaper->escapeHtml($this->_getUploadUrl());
        $spacerImage = $this->_assetRepo->getUrl('images/spacer.gif');
        $imagePlaceholderText = __('Click here or drag and drop to add images');
        $deleteImageText = __('Delete image');
        $makeBaseText = __('Make Base');
        $hiddenText = __('Hidden');
        $imageManagementText = __('Image Management');
        /** @var $product \Magento\Catalog\Model\Product */
        $html = <<<HTML
<div id="{$htmlId}-container" class="images"
    data-mage-init='{"baseImage":{}}'
    data-max-file-size="{$this->_getFileMaxSize()}"
    >
    <div class="image image-placeholder">
        <input type="file" name="image" data-url="{$uploadUrl}" multiple="multiple" />
        <img class="spacer" src="{$spacerImage}"/>
        <p class="image-placeholder-text">{$imagePlaceholderText}</p>
    </div>
    <script id="{$htmlId}-template" class="image-template" type="text/x-jquery-tmpl">
        <div class="image">
            <img class="spacer" src="{$spacerImage}"/>
            <img class="product-image" src="\${url}" data-position="\${position}" alt="\${label}" />
            <div class="actions">
                <button class="action-delete" data-role="delete-button" title="{$deleteImageText}">
                    <span>{$deleteImageText}</span>
                </button>
                <button class="action-make-base" data-role="make-base-button" title="{$makeBaseText}">
                    <span>{$makeBaseText}</span>
                </button>
                <div class="draggable-handle"></div>
            </div>
            <div class="image-label"></div>
            <div class="image-fade"><span>{$hiddenText}</span></div>
        </div>
    </script>
</div>
<span class="action-manage-images" data-activate-tab="image-management">
    <span>{$imageManagementText}</span>
</span>
<script>
    require([
        'jquery'
    ],function(\$){

        'use strict';

        \$('[data-activate-tab=image-management]')
            .on('click.toggleImageManagementTab', function() {
                \$('#product_info_tabs_image-management').trigger('click');
            });
    });
</script>

HTML;
        return $html;
    }
开发者ID:aiesh,项目名称:magento2,代码行数:64,代码来源:BaseImage.php

示例3: getDefaultPlaceholderUrl

 /**
  * @return string
  */
 protected function getDefaultPlaceholderUrl()
 {
     try {
         $url = $this->_assetRepo->getUrl($this->getPlaceholder());
     } catch (\Exception $e) {
         $this->_logger->critical($e);
         $url = $this->_urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']);
     }
     return $url;
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:13,代码来源:Image.php

示例4: testGetUrl

 /**
  * @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', []));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:RepositoryTest.php

示例5: getSmallImageUrl

 /**
  * Retrieve small image url
  *
  * @param ModelProduct|\Magento\Framework\DataObject $product
  * @return string|bool
  */
 public function getSmallImageUrl($product)
 {
     $url = false;
     $attribute = $product->getResource()->getAttribute('small_image');
     if (!$product->getSmallImage()) {
         $url = $this->_assetRepo->getUrl('Magento_Catalog::images/product/placeholder/small_image.jpg');
     } elseif ($attribute) {
         $url = $attribute->getFrontend()->getUrl($product);
     }
     return $url;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:17,代码来源:Product.php

示例6: _getPreviewHtml

 /**
  * Return File preview link HTML
  *
  * @return string
  */
 protected function _getPreviewHtml()
 {
     $html = '';
     if ($this->getValue() && !is_array($this->getValue())) {
         $image = ['alt' => __('Download'), 'title' => __('Download'), 'src' => $this->_assetRepo->getUrl('images/fam_bullet_disk.gif'), 'class' => 'v-middle'];
         $url = $this->_getPreviewUrl();
         $html .= '<span>';
         $html .= '<a href="' . $url . '">' . $this->_drawElementHtml('img', $image) . '</a> ';
         $html .= '<a href="' . $url . '">' . __('Download') . '</a>';
         $html .= '</span>';
     }
     return $html;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:File.php

示例7: getPlaceholderImageUrl

 /**
  * Get image URL of WYSIWYG placeholder image
  *
  * @param string $type
  * @return string
  */
 public function getPlaceholderImageUrl($type)
 {
     $placeholder = false;
     $widget = $this->getWidgetByClassType($type);
     if (is_array($widget) && isset($widget['placeholder_image'])) {
         $placeholder = (string) $widget['placeholder_image'];
     }
     if ($placeholder) {
         $asset = $this->assetRepo->createAsset($placeholder);
         $placeholder = $this->assetSource->getFile($asset);
         if ($placeholder) {
             return $asset->getUrl();
         }
     }
     return $this->assetRepo->getUrl('Magento_Widget::placeholder.gif');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:Widget.php

示例8: getConfig

 /**
  * Return Wysiwyg config as \Magento\Framework\DataObject
  *
  * Config options description:
  *
  * enabled:                 Enabled Visual Editor or not
  * hidden:                  Show Visual Editor on page load or not
  * use_container:           Wrap Editor contents into div or not
  * no_display:              Hide Editor container or not (related to use_container)
  * translator:              Helper to translate phrases in lib
  * files_browser_*:         Files Browser (media, images) settings
  * encode_directives:       Encode template directives with JS or not
  *
  * @param array|\Magento\Framework\DataObject $data Object constructor params to override default config values
  * @return \Magento\Framework\DataObject
  */
 public function getConfig($data = [])
 {
     $config = new \Magento\Framework\DataObject();
     $config->setData(['enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => true, 'add_widgets' => true, 'no_display' => false, 'encode_directives' => true, 'baseStaticUrl' => $this->_assetRepo->getStaticViewFileContext()->getBaseUrl(), 'baseStaticDefaultUrl' => str_replace('index.php/', '', $this->_backendUrl->getBaseUrl()) . $this->filesystem->getUri(DirectoryList::STATIC_VIEW) . '/', 'directives_url' => $this->_backendUrl->getUrl('cms/wysiwyg/directive'), 'popup_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'), 'content_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'), 'width' => '100%', 'height' => '500px', 'plugins' => []]);
     $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));
     if ($this->_authorization->isAllowed('Magento_Cms::media_gallery')) {
         $config->addData(['add_images' => true, 'files_browser_window_url' => $this->_backendUrl->getUrl('cms/wysiwyg_images/index'), 'files_browser_window_width' => $this->_windowSize['width'], 'files_browser_window_height' => $this->_windowSize['height']]);
     }
     if (is_array($data)) {
         $config->addData($data);
     }
     if ($config->getData('add_variables')) {
         $settings = $this->_variableConfig->getWysiwygPluginSettings($config);
         $config->addData($settings);
     }
     if ($config->getData('add_widgets')) {
         $settings = $this->_widgetConfig->getPluginSettings($config);
         $config->addData($settings);
     }
     return $config;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:37,代码来源:Config.php

示例9: getFilesCollection

 /**
  * Return files
  *
  * @param string $path Parent directory path
  * @param string $type Type of storage, e.g. image, media etc.
  * @return \Magento\Framework\Data\Collection\Filesystem
  */
 public function getFilesCollection($path, $type = null)
 {
     if ($this->_coreFileStorageDb->checkDbUsage()) {
         $files = $this->_storageDatabaseFactory->create()->getDirectoryFiles($path);
         /** @var \Magento\MediaStorage\Model\File\Storage\File $fileStorageModel */
         $fileStorageModel = $this->_storageFileFactory->create();
         foreach ($files as $file) {
             $fileStorageModel->saveFile($file);
         }
     }
     $collection = $this->getCollection($path)->setCollectDirs(false)->setCollectFiles(true)->setCollectRecursively(false)->setOrder('mtime', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
     // Add files extension filter
     if ($allowed = $this->getAllowedExtensions($type)) {
         $collection->setFilesFilter('/\\.(' . implode('|', $allowed) . ')$/i');
     }
     // prepare items
     foreach ($collection as $item) {
         $item->setId($this->_cmsWysiwygImages->idEncode($item->getBasename()));
         $item->setName($item->getBasename());
         $item->setShortName($this->_cmsWysiwygImages->getShortFilename($item->getBasename()));
         $item->setUrl($this->_cmsWysiwygImages->getCurrentUrl() . $item->getBasename());
         if ($this->isImage($item->getBasename())) {
             $thumbUrl = $this->getThumbnailUrl($item->getFilename(), true);
             // generate thumbnail "on the fly" if it does not exists
             if (!$thumbUrl) {
                 $thumbUrl = $this->_backendUrl->getUrl('cms/*/thumbnail', ['file' => $item->getId()]);
             }
             $size = @getimagesize($item->getFilename());
             if (is_array($size)) {
                 $item->setWidth($size[0]);
                 $item->setHeight($size[1]);
             }
         } else {
             $thumbUrl = $this->_assetRepo->getUrl(self::THUMB_PLACEHOLDER_PATH_SUFFIX);
         }
         $item->setThumbUrl($thumbUrl);
     }
     return $collection;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:46,代码来源:Storage.php

示例10: __toString

 /**
  * Full url to new image
  *
  * @return string
  */
 public function __toString()
 {
     try {
         if ($this->getImageFile()) {
             $this->getModel()->setBaseFile($this->getImageFile());
         } else {
             $this->getModel()->setBaseFile($this->getItem()->getData($this->getModel()->getDestinationSubDir()));
         }
         if ($this->getModel()->isCached()) {
             return $this->getModel()->getUrl();
         } else {
             if ($this->scheduleResize) {
                 $this->getModel()->resize();
             }
             if ($this->scheduleCrop) {
                 $this->getModel()->crop();
             }
             $url = $this->getModel()->saveFile()->getUrl();
         }
     } catch (\Exception $e) {
         $url = $this->assetRepo->getUrl($this->getPlaceholder());
     }
     return $url;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:Image.php

示例11: getConfig

 /**
  * Gather information to be sent to javascript method renderer
  *
  * @return array
  */
 public function getConfig()
 {
     return $this->methodInstance->isAvailable() ? ['payment' => [$this->methodCode => ['bannerUrl' => $this->_scopeConfig->getValue('payment/mercadopago_custom/banner_checkout'), 'country' => strtoupper($this->_scopeConfig->getValue('payment/mercadopago/country', 'default', $this->_storeManager->getStore()->getId())), 'grand_total' => $this->_checkoutSession->getQuote()->getGrandTotal(), 'base_url' => $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK), 'success_url' => $this->methodInstance->getConfigData('order_place_redirect_url'), 'logEnabled' => $this->_scopeConfig->getValue('payment/mercadopago/logs', 'default', $this->_storeManager->getStore()->getId()), 'discount_coupon' => $this->_scopeConfig->isSetFlag('payment/mercadopago_custom/coupon_mercadopago', 'default', $this->_storeManager->getStore()->getId()), 'route' => $this->_request->getRouteName(), 'public_key' => $this->_scopeConfig->getValue('payment/mercadopago_custom/public_key'), 'customer' => $this->methodInstance->getCustomerAndCards(), 'loading_gif' => $this->_assetRepo->getUrl('MercadoPago_Core::images/loading.gif'), 'text-currency' => __('$'), 'text-choice' => __('Choice'), 'default-issuer' => __('Default issuer'), 'text-installment' => __('Enter the card number'), 'logoUrl' => $this->_assetRepo->getUrl("MercadoPago_Core::images/mp_logo.png")]]] : [];
 }
开发者ID:SummaSolutions,项目名称:cart-magento2,代码行数:9,代码来源:CustomConfigProvider.php

示例12: getRemoveLinkHtml

 /**
  * @return string
  */
 public function getRemoveLinkHtml()
 {
     $src = $this->_assetRepo->getUrl('images/rule_component_remove.gif');
     $html = ' <span class="rule-param"><a href="javascript:void(0)" class="rule-param-remove" title="' . __('Remove') . '"><img src="' . $src . '"  alt="" class="v-middle" /></a></span>';
     return $html;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:AbstractCondition.php

示例13: getPreviewImageDefaultUrl

 /**
  * Return default themes preview image url
  *
  * @return string
  */
 public function getPreviewImageDefaultUrl()
 {
     return $this->assetRepo->getUrl(self::DEFAULT_PREVIEW_IMAGE);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:Path.php

示例14: getUrl

 /**
  * Absolute url to file
  *
  * @return string
  */
 public function getUrl()
 {
     if ($this->newFile === true) {
         $url = $this->assetRepo->getUrl("Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg");
     } else {
         $baseDir = $this->baseMediaPath;
         $path = str_replace($baseDir, '', $this->newFile);
         $url = $this->baseMediaUrl . $path;
     }
     return $url;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:Image.php

示例15: getUrl

 /**
  * @return string
  */
 public function getUrl()
 {
     if ($this->_newFile === true) {
         $url = $this->_assetRepo->getUrl("Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg");
     } else {
         $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $this->_newFile;
     }
     return $url;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:12,代码来源:Image.php


注:本文中的Magento\Framework\View\Asset\Repository::getUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。