本文整理匯總了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);
}
}
}
示例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'));
}
示例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());
}
示例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;
}
示例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, '');
}
示例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, '');
}