當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。