本文整理汇总了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;
}
示例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));
}
示例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());
}
示例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;
}