Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getDownloadDataForPlugin example
$plugin
=
$this
->pluginRepository->
search
(
$criteria
,
$context
)
->
first
(
)
;
if
(
$plugin
!== null &&
$plugin
->
getManagedByComposer
(
)
&& !
str_starts_with
(
$plugin
->
getPath
(
)
?? '',
$this
->relativePluginDir
)
)
{
if
(
Feature::
isActive
(
'v6.6.0.0'
)
)
{
throw
StoreException::
cannotDeleteManaged
(
$plugin
->
getName
(
)
)
;
}
throw
new
CanNotDownloadPluginManagedByComposerException
(
'can not download plugins managed by composer from store api'
)
;
}
try
{
$data
=
$this
->storeClient->
getDownloadDataForPlugin
(
$technicalName
,
$context
)
;
}
catch
(
ClientException
$e
)
{
throw
new
StoreApiException
(
$e
)
;
}
$this
->pluginManagementService->
downloadStorePlugin
(
$data
,
$context
)
;
return
$data
;
}
}
$context
= Context::
createDefaultContext
(
)
;
$pluginName
=
(string)
$input
->
getOption
(
'pluginName'
)
;
$user
=
$input
->
getOption
(
'user'
)
;
$context
=
$this
->
getUserContextFromInput
(
$user
,
$context
)
;
$this
->
validatePluginIsNotManagedByComposer
(
$pluginName
,
$context
)
;
try
{
$data
=
$this
->storeClient->
getDownloadDataForPlugin
(
$pluginName
,
$context
)
;
}
catch
(
ClientException
$exception
)
{
throw
new
StoreApiException
(
$exception
)
;
}
$this
->pluginManagementService->
downloadStorePlugin
(
$data
,
$context
)
;
try
{
$plugin
=
$this
->
getPluginFromInput
(
$pluginName
,
$context
)
;
if
(
$plugin
->
getUpgradeVersion
(
)
)
{
$this
->pluginLifecycleService->
updatePlugin
(
$plugin
,
$context
)
;
}