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


PHP Asset\Repository类代码示例

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


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

示例1: __construct

 /**
  * @param \Magento\Framework\RequireJs\Config\File\Collector\Aggregated $fileSource
  * @param \Magento\Framework\View\DesignInterface $design
  * @param \Magento\Framework\Filesystem $appFilesystem
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  */
 public function __construct(\Magento\Framework\RequireJs\Config\File\Collector\Aggregated $fileSource, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Filesystem $appFilesystem, \Magento\Framework\View\Asset\Repository $assetRepo)
 {
     $this->fileSource = $fileSource;
     $this->design = $design;
     $this->baseDir = $appFilesystem->getDirectoryRead(DirectoryList::ROOT);
     $this->staticContext = $assetRepo->getStaticViewFileContext();
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:13,代码来源:Config.php

示例2: setUp

 protected function setUp()
 {
     $baseUrl = 'http://example.com/pub/static/';
     $path = 'frontend/Magento/blank/en_US';
     $this->context = $this->getMock('\\Magento\\Framework\\View\\Asset\\File\\Context', null, [$baseUrl, DirectoryList::STATIC_VIEW, $path]);
     $this->assetRepo = $this->getMock('Magento\\Framework\\View\\Asset\\Repository', [], [], '', false);
     $this->assetRepo->expects($this->any())->method('getStaticViewFileContext')->will($this->returnValue($this->context));
     $this->object = new \Magento\Framework\View\Asset\NotationResolver\Variable($this->assetRepo);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:VariableTest.php

示例3: testExecute

 /**
  * Run test for execute method
  */
 public function testExecute()
 {
     /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass();
     $assetMock = $this->getMockBuilder(LocalInterface::class)->getMockForAbstractClass();
     $this->validatorMock->expects(self::once())->method('isValid')->with(self::LOCALE_TEST_VALUE)->willReturn(true);
     $message = sprintf('<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>', self::AREA_TEST_VALUE, self::LOCALE_TEST_VALUE, self::THEME_TEST_VALUE, self::TYPE_TEST_VALUE);
     $outputMock->expects(self::at(0))->method('writeln')->with($message);
     $outputMock->expects(self::at(1))->method('writeln')->with('<comment>-> file-test-value/test/file</comment>');
     $outputMock->expects(self::at(2))->method('writeln')->with('<info>Successfully processed.</info>');
     $this->assetRepositoryMock->expects(self::once())->method('createAsset')->with('file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE, ['area' => self::AREA_TEST_VALUE, 'theme' => self::THEME_TEST_VALUE, 'locale' => self::LOCALE_TEST_VALUE])->willReturn($assetMock);
     $this->assetPublisherMock->expects(self::once())->method('publish')->with($assetMock);
     $assetMock->expects(self::once())->method('getFilePath')->willReturn(self::FILE_TEST_VALUE);
     $this->sourceThemeDeployCommand->run($this->getInputMock(), $outputMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:SourceThemeDeployCommandTest.php

示例4: _getFilePathByType

 /**
  * Get file path by type
  *
  * @param string $type
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return string
  * @throws \Magento\Framework\Exception
  */
 protected function _getFilePathByType($type, $theme)
 {
     if (!isset($this->_fileNames[$type])) {
         throw new \Magento\Framework\Exception("Unknown control configuration type: \"{$type}\"");
     }
     return $this->assetRepo->createAsset($this->_fileNames[$type], ['area' => \Magento\Framework\View\DesignInterface::DEFAULT_AREA, 'themeModel' => $theme])->getSourceFile();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Factory.php

示例5: testConvertModuleNotationToPathModularSeparator

 /**
  * @param string $assetRelPath
  * @param string $relatedFieldId
  * @param string $similarRelPath
  * @param string $expectedResult
  * @dataProvider convertModuleNotationToPathModularSeparatorDataProvider
  */
 public function testConvertModuleNotationToPathModularSeparator($assetRelPath, $relatedFieldId, $similarRelPath, $expectedResult)
 {
     $similarAsset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $similarAsset->expects($this->any())->method('getPath')->will($this->returnValue($similarRelPath));
     $this->asset->expects($this->once())->method('getPath')->will($this->returnValue($assetRelPath));
     $this->assetRepo->expects($this->once())->method('createSimilar')->with($relatedFieldId, $this->asset)->will($this->returnValue($similarAsset));
     $this->assertEquals($expectedResult, $this->object->convertModuleNotationToPath($this->asset, $relatedFieldId));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:ModuleTest.php

示例6: testGetTranslationFilePath

 public function testGetTranslationFilePath()
 {
     $path = 'path';
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->atLeastOnce())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path);
     $this->assertEquals($path, $this->model->getTranslationFilePath());
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:8,代码来源:FileManagerTest.php

示例7: testGetViewFileUrl

 /**
  * @param bool $isSecure
  * @dataProvider getViewFileUrlDataProvider
  */
 public function testGetViewFileUrl($isSecure)
 {
     $this->request->expects($this->once())->method('isSecure')->will($this->returnValue($isSecure));
     $this->assetRepo->expects($this->once())->method('getUrlWithParams')->with('some file', $this->callback(function ($value) use($isSecure) {
         return isset($value['_secure']) && $value['_secure'] === $isSecure;
     }))->will($this->returnValue('result url'));
     $this->assertEquals('result url', $this->model->getViewFileUrl('some file'));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:12,代码来源:ReviewTest.php

示例8: updateTranslationFileContent

 /**
  * @param string $content
  * @return void
  */
 public function updateTranslationFileContent($content)
 {
     $translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
     if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
         $this->driverFile->createDirectory($translationDir);
     }
     $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:FileManager.php

示例9: updateTranslationFileContent

 /**
  * @param string $content
  * @return void
  */
 public function updateTranslationFileContent($content)
 {
     $translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
     if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
         $this->driverFile->createDirectory($translationDir, \Magento\Framework\Filesystem\Driver\File::WRITEABLE_DIRECTORY_MODE);
     }
     $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:12,代码来源:FileManager.php

示例10: renderLessJsScripts

 /**
  * Injecting less.js compiler
  *
  * @param array $resultGroups
  *
  * @return mixed
  */
 private function renderLessJsScripts($resultGroups)
 {
     // less js have to be injected before any *.js in developer mode
     $lessJsConfigAsset = $this->assetRepo->createAsset('less/config.less.js');
     $resultGroups['js'] .= sprintf('<script src="%s"></script>' . "\n", $lessJsConfigAsset->getUrl());
     $lessJsAsset = $this->assetRepo->createAsset('less/less.min.js');
     $resultGroups['js'] .= sprintf('<script src="%s"></script>' . "\n", $lessJsAsset->getUrl());
     return $resultGroups;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:16,代码来源:Renderer.php

示例11: getViewFileUrl

 /**
  * 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 '';
     }
 }
开发者ID:smart2pay,项目名称:magento20,代码行数:16,代码来源:ConfigProvider.php

示例12: getPlaceholderValue

 /**
  * Retrieves the value of a given placeholder
  *
  * @param string $placeholder
  * @return string
  */
 public function getPlaceholderValue($placeholder)
 {
     $context = $this->assetRepo->getStaticViewFileContext();
     switch ($placeholder) {
         case self::VAR_BASE_URL_PATH:
             return $context->getBaseUrl() . $context->getPath();
         default:
             return '';
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Variable.php

示例13: testCreateTranslateConfigAsset

 public function testCreateTranslateConfigAsset()
 {
     $path = 'relative path';
     $expectedPath = $path . '/' . FileManager::TRANSLATION_CONFIG_FILE_NAME;
     $fileMock = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->once())->method('getPath')->willReturn($path);
     $this->assetRepoMock->expects($this->once())->method('createArbitrary')->with($expectedPath, '')->willReturn($fileMock);
     $this->assertSame($fileMock, $this->model->createTranslateConfigAsset());
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:11,代码来源:FileManagerTest.php

示例14: testCreateRequireJsAssetDevMode

 public function testCreateRequireJsAssetDevMode()
 {
     $this->config->expects($this->once())->method('getConfigFileRelativePath')->will($this->returnValue('requirejs/file.js'));
     $this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->dir));
     $this->assetRepo->expects($this->once())->method('createArbitrary')->with('requirejs/file.js', '')->will($this->returnValue($this->asset));
     $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER));
     $this->dir->expects($this->never())->method('isExist');
     $data = 'requirejs config data';
     $this->config->expects($this->once())->method('getConfig')->will($this->returnValue($data));
     $this->dir->expects($this->once())->method('writeFile')->with('requirejs/file.js', $data);
     $this->assertSame($this->asset, $this->object->createRequireJsConfigAsset());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:FileManagerTest.php

示例15: 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];
     }
     $config = $this->viewConfigFactory->create();
     $this->viewConfigs[$key] = $config;
     return $config;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:Config.php


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