Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getUpdates example
if
(
!\
is_string
(
$version
)
)
{
throw
new
RuntimeException
(
'Parameter shopware.release.version has to be an string'
)
;
}
}
$plugins
=
$this
->container->
get
(
\Shopware\Bundle\PluginInstallerBundle\Service\PluginLocalService::
class
)
->
getPluginsForUpdateCheck
(
)
;
$domain
=
$this
->container->
get
(
'shopware_plugininstaller.account_manager_service'
)
->
getDomain
(
)
;
$service
=
$this
->container->
get
(
'shopware_plugininstaller.plugin_service_view'
)
;
$request
=
new
UpdateListingRequest
(
'',
$version
,
$domain
,
$plugins
)
;
/** @var UpdateResultStruct $updates */
$updates
=
$service
->
getUpdates
(
$request
)
;
$plugins
=
$updates
->
getPlugins
(
)
;
$result
=
[
]
;
foreach
(
$plugins
as
$plugin
)
{
$result
[
]
=
[
$plugin
->
getId
(
)
,
$plugin
->
getTechnicalName
(
)
,
$plugin
->
getLabel
(
)
,
$plugin
->
getVersion
(
)
,
$plugin
->
getAvailableVersion
(
)
,
]
;
}
'delivery_mail',
'invoice_mail',
]
;
public
function
getCreationTimestamp
(
)
: int
{
return
1624967118;
}
public
function
update
(
Connection
$connection
)
: void
{
foreach
(
self::
getUpdates
(
)
as
$update
)
{
$this
->
updateMail
(
$update
,
$connection
)
;
}
}
/** * @return array<MailUpdate> */
public
static
function
getUpdates
(
)
: array
{
return
\
array_map
(
static
fn
(
string
$mailTypeDirectory
)
: MailUpdate =>
new
MailUpdate
(
$mailTypeDirectory
,
return
$merged
;
}
/** * @return UpdateResultStruct */
public
function
getUpdates
(
UpdateListingRequest
$context
)
{
/** @var UpdateResultStruct $result */
$result
=
$this
->storePluginService->
getUpdates
(
$context
)
;
$store
=
$result
->
getPlugins
(
)
;
$merged
=
$this
->
getAdditionallyLocalData
(
$store
)
;
$plugins
=
[
]
;
foreach
(
$merged
as
$plugin
)
{
if
(
$plugin
->
isUpdateAvailable
(
)
)
{
$plugins
[
]
=
$plugin
;
}
}
$result
->
setPlugins
(
$plugins
)
;
$plugins
=
$this
->
get
(
PluginLocalService::
class
)
->
getPluginsForUpdateCheck
(
)
;
$context
=
new
UpdateListingRequest
(
$this
->
getLocale
(
)
,
$this
->
getVersion
(
)
,
$this
->
getDomain
(
)
,
$plugins
)
;
try
{
$updates
=
$this
->
get
(
'shopware_plugininstaller.plugin_service_view'
)
->
getUpdates
(
$context
)
;
}
catch
(
Exception
$e
)
{
$this
->
handleException
(
$e
)
;
return
;
}
$this
->
View
(
)
->
assign
(
[
'success' => true,
'data' =>
array_values
(
$updates
->
getPlugins
(
)
)
,
'loginRecommended' =>
empty
(
$secret
)
&&
$updates
->
isGtcAcceptanceRequired
(
)
,
]
)
;
}