Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
copyAssets example
private
readonly ParameterBagInterface
$parameterBag
)
{
}
/** * @throws PluginNotFoundException */
public
function
copyAssetsFromBundle
(
string
$bundleName
, bool
$force
= false
)
: void
{
$bundle
=
$this
->
getBundle
(
$bundleName
)
;
$this
->
copyAssets
(
$bundle
,
$force
)
;
if
(
$bundle
instanceof Plugin
)
{
foreach
(
$this
->
getAdditionalBundles
(
$bundle
)
as
$bundle
)
{
$this
->
copyAssets
(
$bundle
,
$force
)
;
}
}
}
public
function
copyAssets
(
BundleInterface
$bundle
, bool
$force
= false
)
: void
{
$this
->
copyAssetsFromBundleOrApp
(
return
;
}
foreach
(
$configuration
->
getAssetPaths
(
)
as
$asset
)
{
if
(
mb_strpos
(
(string)
$asset
, '@'
)
=== 0
)
{
$name
=
mb_substr
(
(string)
$asset
, 1
)
;
$config
=
$configurationCollection
->
getByTechnicalName
(
$name
)
;
if
(
!
$config
)
{
throw
new
InvalidThemeException
(
$name
)
;
}
$this
->
copyAssets
(
$config
,
$configurationCollection
,
$outputPath
)
;
continue
;
}
if
(
$asset
[
0
]
!== '/' &&
file_exists
(
$this
->projectDir . '/' .
$asset
)
)
{
$asset
=
$this
->projectDir . '/' .
$asset
;
}
$assets
=
$this
->themeFileImporter->
getCopyBatchInputsForAssets
(
$asset
,
$outputPath
,
$configuration
)
;
CopyBatch::
copy
(
$this
->filesystem, ...
$assets
)
;
}
foreach
(
$this
->kernel->
getBundles
(
)
as
$bundle
)
{
$io
->
writeln
(
sprintf
(
'Copying files for bundle: %s',
$bundle
->
getName
(
)
)
)
;
$this
->assetService->
copyAssetsFromBundle
(
$bundle
->
getName
(
)
,
$input
->
getOption
(
'force'
)
)
;
}
foreach
(
$this
->activeAppsLoader->
getActiveApps
(
)
as
$app
)
{
$io
->
writeln
(
sprintf
(
'Copying files for app: %s',
$app
[
'name'
]
)
)
;
$this
->assetService->
copyAssetsFromApp
(
$app
[
'name'
]
,
$app
[
'path'
]
,
$input
->
getOption
(
'force'
)
)
;
}
$io
->
writeln
(
'Copying files for bundle: Installer'
)
;
$this
->assetService->
copyAssets
(
new
Installer
(
)
,
$input
->
getOption
(
'force'
)
)
;
$publicDir
=
$this
->kernel->
getProjectDir
(
)
. '/public/';
if
(
!
file_exists
(
$publicDir
. '/.htaccess'
)
&&
file_exists
(
$publicDir
. '/.htaccess.dist'
)
)
{
$io
->
writeln
(
'Copying .htaccess.dist to .htaccess'
)
;
copy
(
$publicDir
. '/.htaccess.dist',
$publicDir
. '/.htaccess'
)
;
}
$io
->
success
(
'Successfully copied all bundle files'
)
;
return
self::SUCCESS;
}