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

PHP Asset\Repository类代码示例

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

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



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

 /**
  * {@inheritdoc}
  * @throws \InvalidArgumentException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $area = $input->getOption(self::AREA_OPTION);
     $locale = $input->getOption(self::LOCALE_OPTION);
     $theme = $input->getOption(self::THEME_OPTION);
     $type = $input->getOption(self::TYPE_ARGUMENT);
     $files = $input->getArgument(self::FILE_ARGUMENT);
     if (!$this->validator->isValid($locale)) {
         throw new \InvalidArgumentException($locale . ' argument has invalid value, please run info:language:list for list of available locales');
     }
     if (!preg_match('#^[\\w\\-]+\\/[\\w\\-]+$#', $theme)) {
         throw new \InvalidArgumentException('Value "' . $theme . '" of the option "' . self::THEME_OPTION . '" has invalid format. The format should be "Vendor/theme".');
     }
     $message = sprintf('<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>', $area, $locale, $theme, $type);
     $output->writeln($message);
     foreach ($files as $file) {
         $fileInfo = pathinfo($file);
         $asset = $this->assetRepository->createAsset($fileInfo['dirname'] . DIRECTORY_SEPARATOR . $fileInfo['basename'] . '.' . $type, ['area' => $area, 'theme' => $theme, 'locale' => $locale]);
         try {
             $this->assetPublisher->publish($asset);
         } catch (\Magento\Framework\View\Asset\File\NotFoundException $e) {
             throw new \InvalidArgumentException('Verify entered values of the argument and options. ' . $e->getMessage());
         }
         $output->writeln('<comment>-> ' . $asset->getFilePath() . '</comment>');
     }
     $output->writeln('<info>Successfully processed.</info>');
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:31,代码来源:SourceThemeDeployCommand.php


示例5: _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


示例6: 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


示例7: 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


示例8: 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


示例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);
     }
     $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:FileManager.php


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: getViewFileUrlWithException

 public function getViewFileUrlWithException()
 {
     $params = ['a' => 'b'];
     $paramsSecure = ['a' => 'b', '_secure' => false];
     $fileId = 'file id';
     $fileUrl = 'exception url';
     $this->requestMock->expects($this->once())->method('isSecure')->willReturn(false);
     $exception = new LocalizedException('message');
     $this->repositoryMock->expects($this->once())->method('getUrlWithParams')->with($fileId, $paramsSecure)->willThrowException($exception);
     $this->loggerMock->expects($this->once())->method('critical')->with($exception);
     $this->urlMock->expects($this->once())->method('getUrl')->with('', ['_direct' => 'core/index/notFound'])->willReturn($fileUrl);
     $this->assertEquals($fileUrl, $this->model->getViewFileUrl($fileId, $params));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:CcConfigTest.php


示例18: testExecute

 public function testExecute()
 {
     $file = 'css/styles-m' . '.less';
     $this->configLoader->expects($this->once())->method('load')->with('frontend')->willReturn([]);
     $this->objectManager->expects($this->once())->method('configure');
     $this->sourceFileGeneratorPool->expects($this->once())->method('create')->with('less')->willReturn($this->getMock('Magento\\Framework\\Less\\FileGenerator', [], [], '', false));
     $this->assetRepo->expects($this->once())->method('createAsset')->with($file, ['area' => 'frontend', 'theme' => 'Magento/blank', 'locale' => 'en_US'])->willReturn($this->getMockForAbstractClass('Magento\\Framework\\View\\Asset\\LocalInterface'));
     $this->assetSource->expects($this->once())->method('findSource')->willReturn('/dev/null');
     $this->chainFactory->expects($this->once())->method('create')->willReturn($this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false));
     $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], [], '', false));
     $this->validator->expects($this->once())->method('isValid')->with('en_US')->willReturn(true);
     $commandTester = new CommandTester($this->command);
     $commandTester->execute(['type' => 'less']);
     $this->assertContains('Successfully processed LESS and/or SASS files', $commandTester->getDisplay());
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:CssDeployCommandTest.php


示例19: testGetDefaultEmailLogo

 public function testGetDefaultEmailLogo()
 {
     $model = $this->getModelMock();
     $value = 'urlWithParamsValue';
     $this->assetRepo->method('getUrlWithParams')->with('Magento_Email::logo_email.png', ['area' => \Magento\Framework\App\Area::AREA_FRONTEND])->will($this->returnValue($value));
     $this->assertEquals($value, $model->getDefaultEmailLogo());
 }
开发者ID:kid17,项目名称:magento2,代码行数:7,代码来源:TemplateTest.php


示例20: build

 /**
  * @return File
  */
 public function build()
 {
     $params = ['area' => $this->area, 'theme' => $this->theme, 'locale' => $this->locale, 'module' => $this->module];
     $asset = $this->repository->createAsset($this->path, $params);
     unset($this->path, $this->module, $this->locale, $this->theme, $this->area);
     return $asset;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:AssetBuilder.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Design\ThemeInterface类代码示例发布时间:2022-05-23
下一篇:
PHP View\LayoutInterface类代码示例发布时间: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