Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
PluginPostInstallEvent example
$this
->
runMigrations
(
$installContext
)
;
$installDate
=
new
\
DateTime
(
)
;
$pluginData
[
'installedAt'
]
=
$installDate
->
format
(
Defaults::STORAGE_DATE_TIME_FORMAT
)
;
$plugin
->
setInstalledAt
(
$installDate
)
;
$this
->
updatePluginData
(
$pluginData
,
$shopwareContext
)
;
$pluginBaseClass
->
postInstall
(
$installContext
)
;
$this
->eventDispatcher->
dispatch
(
new
PluginPostInstallEvent
(
$plugin
,
$installContext
)
)
;
}
catch
(
\Throwable
$e
)
{
if
(
$didRunComposerRequire
&&
$plugin
->
getComposerName
(
)
)
{
$this
->executor->
remove
(
$plugin
->
getComposerName
(
)
,
$plugin
->
getName
(
)
)
;
}
throw
$e
;
}
return
$installContext
;
}
$context
= Context::
createDefaultContext
(
)
;
$rulePlugin
=
new
RulePlugin
(
false, ''
)
;
$collection
=
new
MigrationCollection
(
new
MigrationSource
(
'asd',
[
]
)
,
new
MigrationRuntime
(
new
NullConnection
(
)
,
new
NullLogger
(
)
)
,
new
NullConnection
(
)
)
;
return
[
[
new
PluginPostInstallEvent
(
$plugin
,
new
InstallContext
(
$rulePlugin
,
$context
, '', '',
$collection
)
)
]
,
[
new
PluginPostActivateEvent
(
$plugin
,
new
ActivateContext
(
$rulePlugin
,
$context
, '', '',
$collection
)
)
]
,
[
new
PluginPostUpdateEvent
(
$plugin
,
new
UpdateContext
(
$rulePlugin
,
$context
, '', '',
$collection
, ''
)
)
]
,
[
new
PluginPostDeactivateEvent
(
$plugin
,
new
DeactivateContext
(
$rulePlugin
,
$context
, '', '',
$collection
)
)
]
,
[
new
PluginPostUninstallEvent
(
$plugin
,
new
UninstallContext
(
$rulePlugin
,
$context
, '', '',
$collection
, true
)
)
]
,
]
;
}
}
/** * @internal */