當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Repository::createRelated方法代碼示例

本文整理匯總了PHP中Magento\Framework\View\Asset\Repository::createRelated方法的典型用法代碼示例。如果您正苦於以下問題:PHP Repository::createRelated方法的具體用法?PHP Repository::createRelated怎麽用?PHP Repository::createRelated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\View\Asset\Repository的用法示例。


在下文中一共展示了Repository::createRelated方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: replace

 /**
  * Replace @magento_import to @import less instructions
  *
  * @param array $matchedContent
  * @param LocalInterface $asset
  * @return string
  */
 protected function replace(array $matchedContent, LocalInterface $asset)
 {
     $importsContent = '';
     try {
         $matchedFileId = $matchedContent['path'];
         $relatedAsset = $this->assetRepo->createRelated($matchedFileId, $asset);
         $resolvedPath = $relatedAsset->getFilePath();
         $importFiles = $this->fileSource->getFiles($this->getTheme($relatedAsset), $resolvedPath);
         /** @var $importFile \Magento\Framework\View\File */
         foreach ($importFiles as $importFile) {
             $importsContent .= $importFile->getModule() ? "@import '{$importFile->getModule()}::{$resolvedPath}';\n" : "@import '{$matchedFileId}';\n";
         }
     } catch (\LogicException $e) {
         $this->errorHandler->processException($e);
     }
     return $importsContent;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:24,代碼來源:MagentoImport.php

示例2: testCreateRelated

 /**
  * @param string $filePath
  * @param string $resultFilePath
  * @param string $module
  * @return void
  * @dataProvider createRelatedDataProvider
  */
 public function testCreateRelated($filePath, $resultFilePath, $module)
 {
     $originalContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\ContextInterface')->disableOriginalConstructor()->getMock();
     $originalAssetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->setMethods(['getModule', 'getContext'])->getMock();
     $originalAssetMock->expects($this->any())->method('getContext')->willReturn($originalContextMock);
     $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock();
     $this->fileFactoryMock->expects($this->once())->method('create')->with(['source' => $this->sourceMock, 'context' => $originalContextMock, 'filePath' => $resultFilePath, 'module' => $module, 'contentType' => ''])->willReturn($assetMock);
     $this->assertEquals($assetMock, $this->repository->createRelated($filePath, $originalAssetMock));
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:16,代碼來源:RepositoryTest.php

示例3: testCreateRelated

 /**
  * @param string $fileId
  * @param string $relFilePath
  * @param string $relModule
  * @param string $expFilePath
  * @param string $expType
  * @param string $expModule
  * @dataProvider createRelatedDataProvider
  */
 public function testCreateRelated($fileId, $relFilePath, $relModule, $expFilePath, $expType, $expModule)
 {
     $relativeTo = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface');
     $context = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface');
     $relativeTo->expects($this->once())->method('getContext')->will($this->returnValue($context));
     $relativeTo->expects($this->any())->method('getModule')->will($this->returnValue($relModule));
     $relativeTo->expects($this->any())->method('getFilePath')->will($this->returnValue($relFilePath));
     $asset = $this->object->createRelated($fileId, $relativeTo);
     $this->assertInstanceOf('\\Magento\\Framework\\View\\Asset\\File', $asset);
     $this->assertSame($context, $asset->getContext());
     $this->assertEquals($expFilePath, $asset->getFilePath());
     $this->assertEquals($expType, $asset->getContentType());
     $this->assertEquals($expModule, $asset->getModule());
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:23,代碼來源:RepositoryTest.php

示例4: generateRelatedFile

 /**
  * Create file, referenced relatively to an asset
  *
  * @param string $relatedFileId
  * @param LocalInterface $asset
  * @return \Magento\Framework\View\Asset\File
  */
 protected function generateRelatedFile($relatedFileId, LocalInterface $asset)
 {
     $relatedAsset = $this->assetRepo->createRelated($relatedFileId, $asset);
     $this->temporaryFile->createFile($relatedAsset->getPath(), $relatedAsset->getContent());
     return $relatedAsset;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:13,代碼來源:RelatedGenerator.php


注:本文中的Magento\Framework\View\Asset\Repository::createRelated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。