当前位置: 首页>>代码示例>>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;未经允许,请勿转载。