Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setAssetPaths example
if
(
\
array_key_exists
(
'style',
$data
)
&& \
is_array
(
$data
[
'style'
]
)
)
{
$this
->
resolveStyleFiles
(
$data
[
'style'
]
,
$basePath
,
$config
)
;
}
if
(
\
array_key_exists
(
'script',
$data
)
&& \
is_array
(
$data
[
'script'
]
)
)
{
$fileCollection
= FileCollection::
createFromArray
(
$data
[
'script'
]
)
;
$config
->
setScriptFiles
(
$this
->
addBasePathToCollection
(
$fileCollection
,
$basePath
)
)
;
}
if
(
\
array_key_exists
(
'asset',
$data
)
)
{
$config
->
setAssetPaths
(
$this
->
addBasePathToArray
(
$data
[
'asset'
]
,
$basePath
)
)
;
}
if
(
\
array_key_exists
(
'previewMedia',
$data
)
)
{
$config
->
setPreviewMedia
(
$basePath
. \DIRECTORY_SEPARATOR .
$data
[
'previewMedia'
]
)
;
}
if
(
\
array_key_exists
(
'config',
$data
)
)
{
$config
->
setThemeConfig
(
$data
[
'config'
]
)
;
}
if
(
\
array_key_exists
(
'views',
$data
)
)
{
$this
->
createMock
(
CacheInvalidator::
class
)
,
new
MD5ThemePathBuilder
(
)
,
__DIR__,
$this
->
createMock
(
ScssPhpCompiler::
class
)
,
new
MessageBus
(
)
,
0,
false
)
;
$config
=
new
StorefrontPluginConfiguration
(
'test'
)
;
$config
->
setAssetPaths
(
[
'bla'
]
)
;
$pathBuilder
=
new
MD5ThemePathBuilder
(
)
;
static
::
assertEquals
(
'9a11a759d278b4a55cb5e2c3414733c1',
$pathBuilder
->
assemblePath
(
TestDefaults::SALES_CHANNEL, 'test'
)
)
;
try
{
$pathBuilder
->
getDecorated
(
)
;
}
catch
(
DecorationPatternException
$e
)
{
static
::
assertInstanceOf
(
DecorationPatternException::
class
,
$e
)
;
}
$compiler
->
compileTheme
(
$this
->
createMock
(
CacheInvalidator::
class
)
,
new
MD5ThemePathBuilder
(
)
,
$this
->
getContainer
(
)
->
getParameter
(
'kernel.project_dir'
)
,
$this
->
getContainer
(
)
->
get
(
ScssPhpCompiler::
class
)
,
new
MessageBus
(
)
,
0,
false
)
;
$config
=
new
StorefrontPluginConfiguration
(
'test'
)
;
$config
->
setAssetPaths
(
[
'bla'
]
)
;
try
{
$compiler
->
compileTheme
(
TestDefaults::SALES_CHANNEL,
'test',
$config
,
new
StorefrontPluginConfigurationCollection
(
)
,
true,
Context::
createDefaultContext
(
)
)
;
}
catch
(
\Throwable
$throwable
)
{
if
(
!
$handler
)
{
return
;
}
if
(
!
isset
(
$presetData
[
'syncData'
]
[
'importedAssets'
]
)
)
{
$presetData
[
'syncData'
]
[
'importedAssets'
]
=
[
]
;
}
$syncData
=
new
ParameterBag
(
$presetData
[
'syncData'
]
)
;
$this
->
setAssetPaths
(
$syncData
)
;
try
{
$element
=
$handler
->
import
(
$element
,
$syncData
)
;
}
catch
(
Exception
$e
)
{
throw
new
PresetAssetImportException
(
$e
->
getMessage
(
)
)
;
}
$presetData
[
'syncData'
]
=
$syncData
->
all
(
)
;
$preset
->
setPresetData
(
json_encode
(
$presetData
)
)
;
$this
->
synchronizeData
(
$preset
,
$element
)
;
}