本文整理匯總了PHP中Magento\Framework\View\Asset\Repository類的典型用法代碼示例。如果您正苦於以下問題:PHP Repository類的具體用法?PHP Repository怎麽用?PHP Repository使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Repository類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* @param \Magento\Framework\RequireJs\Config\File\Collector\Aggregated $fileSource
* @param \Magento\Framework\View\DesignInterface $design
* @param \Magento\Framework\Filesystem $appFilesystem
* @param \Magento\Framework\View\Asset\Repository $assetRepo
*/
public function __construct(\Magento\Framework\RequireJs\Config\File\Collector\Aggregated $fileSource, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Filesystem $appFilesystem, \Magento\Framework\View\Asset\Repository $assetRepo)
{
$this->fileSource = $fileSource;
$this->design = $design;
$this->baseDir = $appFilesystem->getDirectoryRead(DirectoryList::ROOT);
$this->staticContext = $assetRepo->getStaticViewFileContext();
}
示例2: setUp
protected function setUp()
{
$baseUrl = 'http://example.com/pub/static/';
$path = 'frontend/Magento/blank/en_US';
$this->context = $this->getMock('\\Magento\\Framework\\View\\Asset\\File\\Context', null, [$baseUrl, DirectoryList::STATIC_VIEW, $path]);
$this->assetRepo = $this->getMock('Magento\\Framework\\View\\Asset\\Repository', [], [], '', false);
$this->assetRepo->expects($this->any())->method('getStaticViewFileContext')->will($this->returnValue($this->context));
$this->object = new \Magento\Framework\View\Asset\NotationResolver\Variable($this->assetRepo);
}
示例3: testExecute
/**
* Run test for execute method
*/
public function testExecute()
{
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */
$outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass();
$assetMock = $this->getMockBuilder(LocalInterface::class)->getMockForAbstractClass();
$this->validatorMock->expects(self::once())->method('isValid')->with(self::LOCALE_TEST_VALUE)->willReturn(true);
$message = sprintf('<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>', self::AREA_TEST_VALUE, self::LOCALE_TEST_VALUE, self::THEME_TEST_VALUE, self::TYPE_TEST_VALUE);
$outputMock->expects(self::at(0))->method('writeln')->with($message);
$outputMock->expects(self::at(1))->method('writeln')->with('<comment>-> file-test-value/test/file</comment>');
$outputMock->expects(self::at(2))->method('writeln')->with('<info>Successfully processed.</info>');
$this->assetRepositoryMock->expects(self::once())->method('createAsset')->with('file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE, ['area' => self::AREA_TEST_VALUE, 'theme' => self::THEME_TEST_VALUE, 'locale' => self::LOCALE_TEST_VALUE])->willReturn($assetMock);
$this->assetPublisherMock->expects(self::once())->method('publish')->with($assetMock);
$assetMock->expects(self::once())->method('getFilePath')->willReturn(self::FILE_TEST_VALUE);
$this->sourceThemeDeployCommand->run($this->getInputMock(), $outputMock);
}
示例4: _getFilePathByType
/**
* Get file path by type
*
* @param string $type
* @param \Magento\Framework\View\Design\ThemeInterface $theme
* @return string
* @throws \Magento\Framework\Exception
*/
protected function _getFilePathByType($type, $theme)
{
if (!isset($this->_fileNames[$type])) {
throw new \Magento\Framework\Exception("Unknown control configuration type: \"{$type}\"");
}
return $this->assetRepo->createAsset($this->_fileNames[$type], ['area' => \Magento\Framework\View\DesignInterface::DEFAULT_AREA, 'themeModel' => $theme])->getSourceFile();
}
示例5: testConvertModuleNotationToPathModularSeparator
/**
* @param string $assetRelPath
* @param string $relatedFieldId
* @param string $similarRelPath
* @param string $expectedResult
* @dataProvider convertModuleNotationToPathModularSeparatorDataProvider
*/
public function testConvertModuleNotationToPathModularSeparator($assetRelPath, $relatedFieldId, $similarRelPath, $expectedResult)
{
$similarAsset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false);
$similarAsset->expects($this->any())->method('getPath')->will($this->returnValue($similarRelPath));
$this->asset->expects($this->once())->method('getPath')->will($this->returnValue($assetRelPath));
$this->assetRepo->expects($this->once())->method('createSimilar')->with($relatedFieldId, $this->asset)->will($this->returnValue($similarAsset));
$this->assertEquals($expectedResult, $this->object->convertModuleNotationToPath($this->asset, $relatedFieldId));
}
示例6: testGetTranslationFilePath
public function testGetTranslationFilePath()
{
$path = 'path';
$contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
$this->assetRepoMock->expects($this->atLeastOnce())->method('getStaticViewFileContext')->willReturn($contextMock);
$contextMock->expects($this->atLeastOnce())->method('getPath')->willReturn($path);
$this->assertEquals($path, $this->model->getTranslationFilePath());
}
示例7: testGetViewFileUrl
/**
* @param bool $isSecure
* @dataProvider getViewFileUrlDataProvider
*/
public function testGetViewFileUrl($isSecure)
{
$this->request->expects($this->once())->method('isSecure')->will($this->returnValue($isSecure));
$this->assetRepo->expects($this->once())->method('getUrlWithParams')->with('some file', $this->callback(function ($value) use($isSecure) {
return isset($value['_secure']) && $value['_secure'] === $isSecure;
}))->will($this->returnValue('result url'));
$this->assertEquals('result url', $this->model->getViewFileUrl('some file'));
}
示例8: updateTranslationFileContent
/**
* @param string $content
* @return void
*/
public function updateTranslationFileContent($content)
{
$translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
$this->driverFile->createDirectory($translationDir);
}
$this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
}
示例9: updateTranslationFileContent
/**
* @param string $content
* @return void
*/
public function updateTranslationFileContent($content)
{
$translationDir = $this->directoryList->getPath(DirectoryList::STATIC_VIEW) . \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath();
if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) {
$this->driverFile->createDirectory($translationDir, \Magento\Framework\Filesystem\Driver\File::WRITEABLE_DIRECTORY_MODE);
}
$this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content);
}
示例10: renderLessJsScripts
/**
* Injecting less.js compiler
*
* @param array $resultGroups
*
* @return mixed
*/
private function renderLessJsScripts($resultGroups)
{
// less js have to be injected before any *.js in developer mode
$lessJsConfigAsset = $this->assetRepo->createAsset('less/config.less.js');
$resultGroups['js'] .= sprintf('<script src="%s"></script>' . "\n", $lessJsConfigAsset->getUrl());
$lessJsAsset = $this->assetRepo->createAsset('less/less.min.js');
$resultGroups['js'] .= sprintf('<script src="%s"></script>' . "\n", $lessJsAsset->getUrl());
return $resultGroups;
}
示例11: getViewFileUrl
/**
* Retrieve url of a view file
*
* @param string $fileId
* @param array $params
* @return string
*/
public function getViewFileUrl($fileId, array $params = [])
{
try {
$params = array_merge(['_secure' => $this->_request->isSecure()], $params);
return $this->_assetRepo->getUrlWithParams($fileId, $params);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
return '';
}
}
示例12: getPlaceholderValue
/**
* Retrieves the value of a given placeholder
*
* @param string $placeholder
* @return string
*/
public function getPlaceholderValue($placeholder)
{
$context = $this->assetRepo->getStaticViewFileContext();
switch ($placeholder) {
case self::VAR_BASE_URL_PATH:
return $context->getBaseUrl() . $context->getPath();
default:
return '';
}
}
示例13: testCreateTranslateConfigAsset
public function testCreateTranslateConfigAsset()
{
$path = 'relative path';
$expectedPath = $path . '/' . FileManager::TRANSLATION_CONFIG_FILE_NAME;
$fileMock = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false);
$contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
$this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock);
$contextMock->expects($this->once())->method('getPath')->willReturn($path);
$this->assetRepoMock->expects($this->once())->method('createArbitrary')->with($expectedPath, '')->willReturn($fileMock);
$this->assertSame($fileMock, $this->model->createTranslateConfigAsset());
}
示例14: testCreateRequireJsAssetDevMode
public function testCreateRequireJsAssetDevMode()
{
$this->config->expects($this->once())->method('getConfigFileRelativePath')->will($this->returnValue('requirejs/file.js'));
$this->fileSystem->expects($this->once())->method('getDirectoryWrite')->with(DirectoryList::STATIC_VIEW)->will($this->returnValue($this->dir));
$this->assetRepo->expects($this->once())->method('createArbitrary')->with('requirejs/file.js', '')->will($this->returnValue($this->asset));
$this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER));
$this->dir->expects($this->never())->method('isExist');
$data = 'requirejs config data';
$this->config->expects($this->once())->method('getConfig')->will($this->returnValue($data));
$this->dir->expects($this->once())->method('writeFile')->with('requirejs/file.js', $data);
$this->assertSame($this->asset, $this->object->createRequireJsConfigAsset());
}
示例15: getViewConfig
/**
* Render view config object for current package and theme
*
* @param array $params
* @return \Magento\Framework\Config\View
*/
public function getViewConfig(array $params = [])
{
$this->assetRepo->updateDesignParams($params);
/** @var $currentTheme \Magento\Framework\View\Design\ThemeInterface */
$currentTheme = $params['themeModel'];
$key = $currentTheme->getCode();
if (isset($this->viewConfigs[$key])) {
return $this->viewConfigs[$key];
}
$config = $this->viewConfigFactory->create();
$this->viewConfigs[$key] = $config;
return $config;
}