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


PHP Repository::createArbitrary方法代码示例

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


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

示例1: execute

 /**
  * Apply customized static files to frontend
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     /** @var $themeFile \Magento\Theme\Model\Theme\File */
     foreach ($this->currentTheme->getCustomization()->getFiles() as $themeFile) {
         try {
             $service = $themeFile->getCustomizationService();
             if ($service instanceof \Magento\Framework\View\Design\Theme\Customization\FileAssetInterface) {
                 $identifier = $themeFile->getData('file_path');
                 $dirPath = \Magento\Framework\View\Design\Theme\Customization\Path::DIR_NAME . '/' . $this->currentTheme->getId();
                 $asset = $this->assetRepo->createArbitrary($identifier, $dirPath, DirectoryList::MEDIA, \Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
                 $this->pageAssets->add($identifier, $asset);
             }
         } catch (\InvalidArgumentException $e) {
             $this->logger->critical($e);
         }
     }
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:24,代码来源:ApplyThemeCustomizationObserver.php

示例2: testCreateArbitrary

 /**
  * @return void
  */
 public function testCreateArbitrary()
 {
     $contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\ContextInterface')->disableOriginalConstructor()->getMock();
     $this->contextFactoryMock->expects($this->once())->method('create')->with(['baseUrl' => '', 'baseDirType' => 'dirType', 'contextPath' => 'dir/path'])->willReturn($contextMock);
     $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock();
     $this->fileFactoryMock->expects($this->once())->method('create')->with(['source' => $this->sourceMock, 'context' => $contextMock, 'filePath' => 'test/file.js', 'module' => '', 'contentType' => ''])->willReturn($assetMock);
     $this->assertEquals($assetMock, $this->repository->createArbitrary('test/file.js', 'dir/path', 'dirType', 'static'));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:RepositoryTest.php

示例3: testCreateArbitrary

 /**
  * @param string $filePath
  * @param string $dirPath
  * @param string $baseUrlType
  * @param string $expectedType
  * @param string $expectedUrl
  * @dataProvider createArbitraryDataProvider
  */
 public function testCreateArbitrary($filePath, $dirPath, $baseUrlType, $expectedType, $expectedUrl)
 {
     $this->baseUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValueMap([[['_type' => 'static'], 'http://example.com/static/'], [['_type' => 'media'], 'http://example.com/media/']]));
     $dirType = 'dirType';
     $asset = $this->object->createArbitrary($filePath, $dirPath, $dirType, $baseUrlType);
     $this->assertInstanceOf('\\Magento\\Framework\\View\\Asset\\File', $asset);
     $this->assertEquals($expectedType, $asset->getContentType());
     $this->assertEquals($expectedUrl, $asset->getUrl());
     $this->assertEquals($dirType, $asset->getContext()->getBaseDirType());
     $anotherAsset = $this->object->createArbitrary('another/path.js', $dirPath, $dirType, $baseUrlType);
     $this->assertSame($anotherAsset->getContext(), $asset->getContext());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:20,代码来源:RepositoryTest.php

示例4: createBundleJsPool

 /**
  * Create a view assets representing the bundle js functionality
  *
  * @return \Magento\Framework\View\Asset\File[]
  */
 public function createBundleJsPool()
 {
     $bundles = [];
     if ($this->appState->getMode() == AppState::MODE_PRODUCTION) {
         $libDir = $this->filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW);
         /** @var $context \Magento\Framework\View\Asset\File\FallbackContext */
         $context = $this->assetRepo->getStaticViewFileContext();
         $bundleDir = $context->getPath() . '/' . Config::BUNDLE_JS_DIR;
         if (!$libDir->isExist($bundleDir)) {
             return [];
         }
         foreach ($libDir->read($bundleDir) as $bundleFile) {
             $relPath = $libDir->getRelativePath($bundleFile);
             $bundles[] = $this->assetRepo->createArbitrary($relPath, '');
         }
     }
     return $bundles;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:23,代码来源:FileManager.php

示例5: createTranslateConfigAsset

 /**
  * Create a view asset representing the requirejs config.config property for inline translation
  *
  * @return \Magento\Framework\View\Asset\File
  */
 public function createTranslateConfigAsset()
 {
     return $this->assetRepo->createArbitrary($this->assetRepo->getStaticViewFileContext()->getPath() . '/' . self::TRANSLATION_CONFIG_FILE_NAME, '');
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:9,代码来源:FileManager.php

示例6: createRequireJsAsset

 /**
  * Create a view asset representing the aggregated configuration file
  *
  * @return \Magento\Framework\View\Asset\File
  */
 public function createRequireJsAsset()
 {
     $relPath = $this->config->getConfigFileRelativePath();
     $this->ensureSourceFile($relPath);
     return $this->assetRepo->createArbitrary($relPath, '');
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:FileManager.php


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