Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
InstallContext example
return
$this
->legacyPluginInstaller->
getPluginBootstrap
(
$plugin
)
;
}
/** * @throws Exception * * @return InstallContext */
public
function
installPlugin
(
Plugin
$plugin
)
{
$context
=
new
InstallContext
(
$plugin
,
$this
->release->
getVersion
(
)
,
$plugin
->
getVersion
(
)
)
;
if
(
$plugin
->
getInstalled
(
)
)
{
return
$context
;
}
if
(
!
$plugin
->
isLegacyPlugin
(
)
)
{
return
$this
->pluginInstaller->
installPlugin
(
$plugin
)
;
}
$result
=
$this
->legacyPluginInstaller->
installPlugin
(
$plugin
)
;
$this
->
applyLegacyResultToContext
(
$result
,
$context
)
;
/** * @throws Exception * * @return InstallContext */
public
function
installPlugin
(
Plugin
$plugin
)
{
$pluginBootstrap
=
$this
->
getPluginByName
(
$plugin
->
getName
(
)
)
;
$context
=
new
InstallContext
(
$plugin
,
$this
->release->
getVersion
(
)
,
$plugin
->
getVersion
(
)
)
;
$this
->requirementValidator->
validate
(
$pluginBootstrap
->
getPath
(
)
. '/plugin.xml',
$this
->release->
getVersion
(
)
)
;
$this
->events->
notify
(
PluginEvent::PRE_INSTALL,
new
PrePluginInstallEvent
(
$context
,
$pluginBootstrap
)
)
;
$this
->
installResources
(
$pluginBootstrap
,
$plugin
)
;
// Makes sure the version is updated in the db after a re-installation
if
(
$plugin
->
getUpdateVersion
(
)
&&
$this
->
hasInfoNewerVersion
(
$plugin
->
getUpdateVersion
(
)
,
$plugin
->
getVersion
(
)
)
)
{
$plugin
->
setVersion
(
$plugin
->
getUpdateVersion
(
)
)
;
}
$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 */
/** * @throws RequirementStackException */
public
function
installPlugin
(
PluginEntity
$plugin
, Context
$shopwareContext
)
: InstallContext
{
$pluginData
=
[
]
;
$pluginBaseClass
=
$this
->
getPluginBaseClass
(
$plugin
->
getBaseClass
(
)
)
;
$pluginVersion
=
$plugin
->
getVersion
(
)
;
$installContext
=
new
InstallContext
(
$pluginBaseClass
,
$shopwareContext
,
$this
->shopwareVersion,
$pluginVersion
,
$this
->
createMigrationCollection
(
$pluginBaseClass
)
)
;
if
(
$plugin
->
getInstalledAt
(
)
)
{
return
$installContext
;
}