• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP View\FileSystem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testGetTemplateFileName

 /**
  * Resolver get template file name test
  *
  * @return void
  */
 public function testGetTemplateFileName()
 {
     $template = 'template.phtml';
     $this->_viewFileSystemMock->expects($this->once())->method('getTemplateFileName')->with($template)->will($this->returnValue('path_to' . $template));
     $this->assertEquals('path_to' . $template, $this->_resolver->getTemplateFileName($template));
     $this->assertEquals('path_to' . $template, $this->_resolver->getTemplateFileName($template));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:ResolverTest.php


示例2: getTemplateFileName

 /**
  * Get template filename
  *
  * @param string $template
  * @param [] $params
  * @return string|bool
  */
 public function getTemplateFileName($template, $params = [])
 {
     $key = $template . '_' . serialize($params);
     if (!isset($this->_templateFilesMap[$key])) {
         $this->_templateFilesMap[$key] = $this->_viewFileSystem->getTemplateFileName($template, $params);
     }
     return $this->_templateFilesMap[$key];
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Resolver.php


示例3: testReferencesFromStaticFiles

 /**
  * Scan references to files from other static files and assert they are correct
  *
  * The CSS or LESS files may refer to other resources using @import or url() notation
  * We want to check integrity of all these references
  * Note that the references may have syntax specific to the Magento preprocessing subsystem
  *
  * @param string $area
  * @param string $themePath
  * @param string $locale
  * @param string $module
  * @param string $filePath
  * @param string $absolutePath
  * @dataProvider referencesFromStaticFilesDataProvider
  */
 public function testReferencesFromStaticFiles($area, $themePath, $locale, $module, $filePath, $absolutePath)
 {
     $contents = file_get_contents($absolutePath);
     preg_match_all(\Magento\Framework\View\Url\CssResolver::REGEX_CSS_RELATIVE_URLS, $contents, $matches);
     foreach ($matches[1] as $relatedResource) {
         if (false !== strpos($relatedResource, '@')) {
             // unable to parse paths with LESS variables/mixins
             continue;
         }
         list($relatedModule, $relatedPath) = \Magento\Framework\View\Asset\Repository::extractModule($relatedResource);
         if ($relatedModule) {
             $fallbackModule = $relatedModule;
         } else {
             if ('less' == pathinfo($filePath, PATHINFO_EXTENSION)) {
                 /**
                  * The LESS library treats the related resources with relative links not in the same way as CSS:
                  * when another LESS file is included, it is embedded directly into the resulting document, but the
                  * relative paths of related resources are not adjusted accordingly to the new root file.
                  * Probably it is a bug of the LESS library.
                  */
                 $this->markTestSkipped("Due to LESS library specifics, the '{$relatedResource}' cannot be tested.");
             }
             $fallbackModule = $module;
             $relatedPath = \Magento\Framework\View\FileSystem::getRelatedPath($filePath, $relatedResource);
         }
         // the $relatedPath will be suitable for feeding to the fallback system
         $this->assertNotEmpty($this->getStaticFile($area, $themePath, $locale, $relatedPath, $fallbackModule), "The related resource cannot be resolved through fallback: '{$relatedResource}'");
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:44,代码来源:StaticFilesTest.php


示例4: testLoadData

 /**
  * @param string $area
  * @param bool $forceReload
  * @param array $cachedData
  * @dataProvider dataProviderForTestLoadData
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function testLoadData($area, $forceReload, $cachedData)
 {
     $this->expectsSetConfig('themeId');
     $this->cache->expects($this->exactly($forceReload ? 0 : 1))->method('load')->will($this->returnValue(serialize($cachedData)));
     if (!$forceReload && $cachedData !== false) {
         $this->translate->loadData($area, $forceReload);
         $this->assertEquals($cachedData, $this->translate->getData());
         return;
     }
     $this->directory->expects($this->any())->method('isExist')->will($this->returnValue(true));
     // _loadModuleTranslation()
     $this->moduleList->expects($this->once())->method('getNames')->will($this->returnValue(['name']));
     $moduleData = ['module original' => 'module translated', 'module theme' => 'module-theme original translated', 'module pack' => 'module-pack original translated', 'module db' => 'module-db original translated'];
     $this->modulesReader->expects($this->any())->method('getModuleDir')->will($this->returnValue('/app/module'));
     $themeData = ['theme original' => 'theme translated', 'module theme' => 'theme translated overwrite', 'module pack' => 'theme-pack translated overwrite', 'module db' => 'theme-db translated overwrite'];
     $this->csvParser->expects($this->any())->method('getDataPairs')->will($this->returnValueMap([['/app/module/en_US.csv', 0, 1, $moduleData], ['/app/module/en_GB.csv', 0, 1, $moduleData], ['/theme.csv', 0, 1, $themeData]]));
     // _loadThemeTranslation()
     $this->viewFileSystem->expects($this->any())->method('getLocaleFileName')->will($this->returnValue('/theme.csv'));
     // _loadPackTranslation
     $packData = ['pack original' => 'pack translated', 'module pack' => 'pack translated overwrite', 'module db' => 'pack-db translated overwrite'];
     $this->packDictionary->expects($this->once())->method('getDictionary')->will($this->returnValue($packData));
     // _loadDbTranslation()
     $dbData = ['db original' => 'db translated', 'module db' => 'db translated overwrite'];
     $this->resource->expects($this->any())->method('getTranslationArray')->will($this->returnValue($dbData));
     $this->cache->expects($this->exactly(1))->method('save');
     $this->translate->loadData($area, $forceReload);
     $expected = ['module original' => 'module translated', 'module theme' => 'theme translated overwrite', 'module pack' => 'pack translated overwrite', 'module db' => 'db translated overwrite', 'theme original' => 'theme translated', 'pack original' => 'pack translated', 'db original' => 'db translated'];
     $this->assertEquals($expected, $this->translate->getData());
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:36,代码来源:TranslateTest.php


示例5: _getThemeTranslationFile

 /**
  * Retrieve translation file for theme
  *
  * @param string $locale
  * @return string
  */
 protected function _getThemeTranslationFile($locale)
 {
     return $this->_viewFileSystem->getLocaleFileName(
         'i18n' . '/' . $locale . '.csv',
         ['area' => $this->getConfig('area')]
     );
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:13,代码来源:Translate.php


示例6: getViewConfig

    /**
     * Render view config object for current package and theme
     *
     * @param array $params
     * @return \Magento\Framework\Config\View
     */
    public function getViewConfig(array $params = [])
    {
        $this->assetRepo->updateDesignParams($params);
        /** @var $currentTheme \Magento\Framework\View\Design\ThemeInterface */
        $currentTheme = $params['themeModel'];
        $key = $currentTheme->getCode();
        if (isset($this->viewConfigs[$key])) {
            return $this->viewConfigs[$key];
        }

        $configFiles = $this->moduleReader->getConfigurationFiles(basename($this->filename))->toArray();
        $themeConfigFile = $currentTheme->getCustomization()->getCustomViewConfigPath();
        if (empty($themeConfigFile)
            || !$this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
        ) {
            $themeConfigFile = $this->viewFileSystem->getFilename($this->filename, $params);
        }
        if ($themeConfigFile
            && $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
        ) {
            $configFiles[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile(
                $this->rootDirectory->getRelativePath($themeConfigFile)
            );
        }
        $config = $this->viewFactory->create($configFiles);

        $this->viewConfigs[$key] = $config;
        return $config;
    }
开发者ID:nblair,项目名称:magescotch,代码行数:35,代码来源:Config.php


示例7: generateLayoutUpdateXml

 /**
  * Generate layout update xml
  *
  * @param string $container
  * @param string $templatePath
  * @return string
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function generateLayoutUpdateXml($container, $templatePath = '')
 {
     $templateFilename = $this->_viewFileSystem->getTemplateFileName($templatePath, ['area' => $this->getArea(), 'themeId' => $this->getThemeId(), 'module' => \Magento\Framework\View\Element\AbstractBlock::extractModuleName($this->getType())]);
     if (!$this->getId() && !$this->isCompleteToCreate() || $templatePath && !is_readable($templateFilename)) {
         return '';
     }
     $parameters = $this->getWidgetParameters();
     $xml = '<body><referenceContainer name="' . $container . '">';
     $template = '';
     if (isset($parameters['template'])) {
         unset($parameters['template']);
     }
     if ($templatePath) {
         $template = ' template="' . $templatePath . '"';
     }
     $hash = $this->mathRandom->getUniqueHash();
     $xml .= '<block class="' . $this->getType() . '" name="' . $hash . '"' . $template . '>';
     foreach ($parameters as $name => $value) {
         if ($name == 'conditions') {
             $name = 'conditions_encoded';
             $value = $this->conditionsHelper->encode($value);
         } elseif (is_array($value)) {
             $value = implode(',', $value);
         }
         if ($name && strlen((string) $value)) {
             $xml .= '<action method="setData">' . '<argument name="name" xsi:type="string">' . $name . '</argument>' . '<argument name="value" xsi:type="string">' . $this->_escaper->escapeHtml($value) . '</argument>' . '</action>';
         }
     }
     $xml .= '</block></referenceContainer></body>';
     return $xml;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:40,代码来源:Instance.php


示例8: relocateRelativeUrls

 /**
  * Adjust relative URLs in CSS content as if the file with this content is to be moved to new location
  *
  * @param string $cssContent
  * @param string $relatedPath
  * @param string $filePath
  * @return mixed
  */
 public function relocateRelativeUrls($cssContent, $relatedPath, $filePath)
 {
     $offset = FileSystem::offsetPath($relatedPath, $filePath);
     $callback = function ($path) use($offset) {
         return FileSystem::normalizePath($offset . '/' . $path);
     };
     return $this->replaceRelativeUrls($cssContent, $callback);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:CssResolver.php


示例9: testGetWidgetSupportedTemplatesByContainersUnknownContainer

 public function testGetWidgetSupportedTemplatesByContainersUnknownContainer()
 {
     $expectedConfigFile = __DIR__ . '/../_files/mappedConfigArray1.php';
     $widget = (include $expectedConfigFile);
     $this->_widgetModelMock->expects($this->once())->method('getWidgetByClassType')->will($this->returnValue($widget));
     $this->_viewFileSystemMock->expects($this->once())->method('getFilename')->will($this->returnValue(''));
     $expectedTemplates = [];
     $this->assertEquals($expectedTemplates, $this->_model->getWidgetSupportedTemplatesByContainer('unknown'));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:9,代码来源:InstanceTest.php


示例10: testToHtmlWithoutRatingData

 public function testToHtmlWithoutRatingData()
 {
     $this->registry->expects($this->any())->method('registry')->will($this->returnValue(false));
     $this->systemStore->expects($this->any())->method('getStoreCollection')->will($this->returnValue(['0' => $this->store]));
     $this->formFactory->expects($this->any())->method('create')->will($this->returnValue($this->form));
     $this->viewFileSystem->expects($this->any())->method('getTemplateFileName')->will($this->returnValue('template_file_name.html'));
     $this->fileSystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->directoryReadInterface));
     $this->block->toHtml();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:FormTest.php


示例11: getTemplateFile

 /**
  * Get absolute path to template
  *
  * @param string|null $template
  * @return string
  */
 public function getTemplateFile($template = null)
 {
     $params = ['module' => $this->getModuleName()];
     $area = $this->getArea();
     if ($area) {
         $params['area'] = $area;
     }
     $templateName = $this->_viewFileSystem->getTemplateFileName($template ?: $this->getTemplate(), $params);
     return $templateName;
 }
开发者ID:kid17,项目名称:magento2,代码行数:16,代码来源:Template.php


示例12: getTemplateFilename

 /**
  * Retrieve full path to an email template file
  *
  * @param string $templateId
  * @param array|null $designParams
  * @return string
  */
 public function getTemplateFilename($templateId, $designParams = [])
 {
     // If design params aren't passed, then use area/module defined in email_templates.xml
     if (!isset($designParams['area'])) {
         $designParams['area'] = $this->getTemplateArea($templateId);
     }
     $module = $this->getTemplateModule($templateId);
     $designParams['module'] = $module;
     $file = $this->_getInfo($templateId, 'file');
     return $this->viewFileSystem->getEmailTemplateFileName($file, $designParams, $module);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:Config.php


示例13: setUp

 protected function setUp()
 {
     $this->_viewFileSystem = $this->getMock('Magento\\Framework\\View\\FileSystem', array('getLocaleFileName', 'getDesignTheme'), array(), '', false);
     $this->_viewFileSystem->expects($this->any())->method('getLocaleFileName')->will($this->returnValue(dirname(__DIR__) . '/Core/Model/_files/design/frontend/test_default/i18n/en_US.csv'));
     $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\ThemeInterface', array());
     $theme->expects($this->any())->method('getId')->will($this->returnValue(10));
     $this->_viewFileSystem->expects($this->any())->method('getDesignTheme')->will($this->returnValue($theme));
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $objectManager->addSharedInstance($this->_viewFileSystem, 'Magento\\Framework\\View\\FileSystem');
     /** @var $moduleReader \Magento\Framework\Module\Dir\Reader */
     $moduleReader = $objectManager->get('Magento\\Framework\\Module\\Dir\\Reader');
     $moduleReader->setModuleDir('Magento_Core', 'i18n', dirname(__DIR__) . '/Core/Model/_files/Magento/Core/i18n');
     $moduleReader->setModuleDir('Magento_Catalog', 'i18n', dirname(__DIR__) . '/Core/Model/_files/Magento/Catalog/i18n');
     /** @var \Magento\Core\Model\View\Design _designModel */
     $this->_designModel = $this->getMock('Magento\\Core\\Model\\View\\Design', array('getDesignTheme'), array($objectManager->get('Magento\\Framework\\StoreManagerInterface'), $objectManager->get('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory'), $objectManager->get('Magento\\Framework\\App\\Config\\ScopeConfigInterface'), $objectManager->get('Magento\\Core\\Model\\ThemeFactory'), $objectManager->get('Magento\\Framework\\Locale\\ResolverInterface'), $objectManager->get('Magento\\Framework\\App\\State'), array('frontend' => 'test_default')));
     $this->_designModel->expects($this->any())->method('getDesignTheme')->will($this->returnValue($theme));
     $objectManager->addSharedInstance($this->_designModel, 'Magento\\Core\\Model\\View\\Design\\Proxy');
     $this->_model = $objectManager->create('Magento\\Framework\\Translate');
     $objectManager->addSharedInstance($this->_model, 'Magento\\Framework\\Translate');
     $objectManager->removeSharedInstance('Magento\\Framework\\Phrase\\Renderer\\Composite');
     $objectManager->removeSharedInstance('Magento\\Framework\\Phrase\\Renderer\\Translate');
     \Magento\Framework\Phrase::setRenderer($objectManager->get('Magento\\Framework\\Phrase\\RendererInterface'));
     $this->_model->loadData(\Magento\Framework\App\Area::AREA_FRONTEND);
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:24,代码来源:TranslateTest.php


示例14: renderPage

 /**
  * Render page template
  *
  * @return string
  * @throws \Exception
  */
 protected function renderPage()
 {
     $fileName = $this->viewFileSystem->getTemplateFileName($this->template);
     if (!$fileName) {
         throw new \InvalidArgumentException('Template "' . $this->template . '" is not found');
     }
     ob_start();
     try {
         extract($this->viewVars, EXTR_SKIP);
         include $fileName;
     } catch (\Exception $exception) {
         ob_end_clean();
         throw $exception;
     }
     $output = ob_get_clean();
     return $output;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:23,代码来源:Page.php


示例15: testGetTemplateFilenameWithNoParams

 /**
  * Ensure that the getTemplateFilename method can be called without design params
  */
 public function testGetTemplateFilenameWithNoParams()
 {
     $this->viewFileSystem->expects($this->once())->method('getEmailTemplateFileName')->with('one.html', ['area' => $this->designParams['area'], 'module' => $this->designParams['module']], 'Fixture_ModuleOne')->will($this->returnValue('_files/Fixture/ModuleOne/view/frontend/email/one.html'));
     $actualResult = $this->model->getTemplateFilename('template_one');
     $this->assertEquals('_files/Fixture/ModuleOne/view/frontend/email/one.html', $actualResult);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:ConfigTest.php


示例16: _getWatermarkFilePath

 /**
  * Get relative watermark file path
  * or false if file not found
  *
  * @return string | bool
  */
 protected function _getWatermarkFilePath()
 {
     $filePath = false;
     if (!($file = $this->getWatermarkFile())) {
         return $filePath;
     }
     $baseDir = $this->_catalogProductMediaConfig->getBaseMediaPath();
     $candidates = array($baseDir . '/watermark/stores/' . $this->_storeManager->getStore()->getId() . $file, $baseDir . '/watermark/websites/' . $this->_storeManager->getWebsite()->getId() . $file, $baseDir . '/watermark/default/' . $file, $baseDir . '/watermark/' . $file);
     foreach ($candidates as $candidate) {
         if ($this->_mediaDirectory->isExist($candidate)) {
             $filePath = $this->_mediaDirectory->getAbsolutePath($candidate);
             break;
         }
     }
     if (!$filePath) {
         $filePath = $this->_viewFileSystem->getStaticFileName($file);
     }
     return $filePath;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:25,代码来源:Image.php


示例17: createRelated

 /**
  * Create a file asset with path relative to specified local asset
  *
  * @param string $fileId
  * @param LocalInterface $relativeTo
  * @return File
  */
 public function createRelated($fileId, LocalInterface $relativeTo)
 {
     list($module, $filePath) = self::extractModule($fileId);
     if ($module) {
         return $this->createSimilar($fileId, $relativeTo);
     }
     $filePath = \Magento\Framework\View\FileSystem::getRelatedPath($relativeTo->getFilePath(), $filePath);
     return $this->createSimilar($filePath, $relativeTo);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:16,代码来源:Repository.php


示例18: testGetFilename

 /**
  * @dataProvider getFilenameDataProvider
  * @magentoAppIsolation enabled
  */
 public function testGetFilename($file, $params)
 {
     $this->_emulateFixtureTheme();
     $this->assertFileExists($this->_viewFileSystem->getFilename($file, $params));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:DesignTest.php


示例19: testGetViewFile

 /**
  * @magentoComponentsDir Magento/Framework/View/_files/Fixture_Module
  */
 public function testGetViewFile()
 {
     $expected = '%s/frontend/Vendor/custom_theme/Fixture_Module/web/fixture_script.js';
     $params = ['theme' => 'Vendor_FrameworkThemeTest/custom_theme'];
     $actual = $this->_model->getStaticFileName('Fixture_Module::fixture_script.js', $params);
     $this->_testExpectedVersusActualFilename($expected, $actual);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:FileSystemTest.php


示例20: render

 /**
  * Render data
  *
  * @param UiComponentInterface $view
  * @param string $template
  * @return string
  */
 public function render(UiComponentInterface $view, $template = '')
 {
     $templateEngine = false;
     if ($template) {
         $extension = pathinfo($template, PATHINFO_EXTENSION);
         $templateEngine = $this->templateEnginePool->get($extension);
     }
     if ($templateEngine) {
         $path = $this->filesystem->getTemplateFileName($template);
         $result = $templateEngine->render($view, $path);
     } else {
         $result = '';
     }
     return $result;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:22,代码来源:Html.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP View\Layout类代码示例发布时间:2022-05-23
下一篇:
PHP View\DesignInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap