Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setStyleFiles example
$criteria
->
addFilter
(
new
EqualsFilter
(
'technicalName', 'ThemeWithMultiInheritance'
)
)
;
$criteria
->
addAssociation
(
'parentThemes'
)
;
/** @var ThemeEntity $theme */
$theme
=
$themeRepository
->
search
(
$criteria
,
$context
)
->
first
(
)
;
}
public
function
testHandleThemeInstallOrUpdateWillRecompileOnlyTouchedTheme
(
)
: void
{
$salesChannelId
=
$this
->
createSalesChannel
(
)
;
$themeId
=
$this
->
createTheme
(
'SimpleTheme',
$salesChannelId
)
;
$installConfig
=
$this
->configFactory->
createFromBundle
(
new
SimpleTheme
(
)
)
;
$installConfig
->
setStyleFiles
(
FileCollection::
createFromArray
(
[
'onlyForFile'
]
)
)
;
$this
->themeServiceMock->
expects
(
static
::
once
(
)
)
->
method
(
'compileThemeById'
)
->
with
(
$themeId
,
static
::
isInstanceOf
(
Context::
class
)
,
static
::
callback
(
fn
(
StorefrontPluginConfigurationCollection
$configs
)
: bool =>
$configs
->
count
(
)
=== 2
)
)
;
$configs
=
new
StorefrontPluginConfigurationCollection
(
[
$this
->configFactory->
createFromBundle
(
new
Storefront
(
)
)
,
$this
->themeRepositoryMock,
$this
->configurationRegistryMock,
$this
->connectionMock
)
;
$this
->context = Context::
createDefaultContext
(
)
;
}
public
function
testThemeUninstallWithoutData
(
)
: void
{
$themeConfig
=
new
StorefrontPluginConfiguration
(
'SimpleTheme'
)
;
$themeConfig
->
setStyleFiles
(
new
FileCollection
(
)
)
;
$themeConfig
->
setScriptFiles
(
new
FileCollection
(
)
)
;
$themeConfig
->
setName
(
'Simple Theme'
)
;
$themeConfig
->
setIsTheme
(
true
)
;
$collection
=
new
StorefrontPluginConfigurationCollection
(
[
$themeConfig
,
]
)
;
$this
->configurationRegistryMock->
expects
(
static
::
once
(
)
)
->
method
(
'getConfigurations'
)
->
willReturn
(
$collection
)
;
return
$config
;
}
private
function
createPluginConfig
(
string
$name
, string
$path
)
: StorefrontPluginConfiguration
{
$config
=
new
StorefrontPluginConfiguration
(
$name
)
;
$config
->
setIsTheme
(
false
)
;
$config
->
setStorefrontEntryFilepath
(
$this
->
getEntryFile
(
$path
)
)
;
$config
->
setBasePath
(
$this
->
stripProjectDir
(
$path
)
)
;
$stylesPath
=
$path
. \DIRECTORY_SEPARATOR . 'Resources/app/storefront/src/scss';
$config
->
setStyleFiles
(
FileCollection::
createFromArray
(
$this
->
getScssEntryFileInDir
(
$stylesPath
)
)
)
;
$scriptPath
=
$path
. \DIRECTORY_SEPARATOR . 'Resources/app/storefront/dist/storefront/js';
$config
->
setScriptFiles
(
FileCollection::
createFromArray
(
$this
->
getFilesInDir
(
$scriptPath
)
)
)
;
return
$config
;
}
private
function
createThemeConfig
(
string
$name
, string
$path
)
: StorefrontPluginConfiguration
{
$pathname
=
$path
. \DIRECTORY_SEPARATOR . 'Resources/theme.json';