Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
SimpleTheme example
$criteria
=
new
Criteria
(
)
;
$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
(
[
new
Callback
(
static
function
DStorefrontPluginConfiguration
$value
)
use
(
&
$_expectedColor
)
: bool
{
return
$value
->
getThemeConfig
(
)
[
'fields'
]
[
'sw-color-brand-primary'
]
[
'value'
]
===
$_expectedColor
; /** @phpstan-ignore-line */
}
)
)
;
$kernel
=
new
class
(
$this
->
getContainer
(
)
->
get
(
'kernel'
)
)
implements
KernelInterface
{
private
readonly SimpleTheme
$simpleTheme
;
public
function
__construct
(
private
readonly Kernel
$kernel
)
{
$this
->simpleTheme =
new
SimpleTheme
(
)
;
}
public
function
getBundles
(
)
: array
{
$bundles
=
$this
->kernel->
getBundles
(
)
;
$bundles
[
$this
->simpleTheme->
getName
(
)
]
=
$this
->simpleTheme;
return
$bundles
;
}
public
function
getBundle
(
string
$name
)
: BundleInterface
{