Plugin - Contexts

Version

6.0.0 or newer

Table of contents

Overview

In this guide, you will learn which plugin contexts exist and what they are used for.

InstallContext

The InstallContext holds the following information.

FieldTypeUsage
plugin\Shopware\Core\Framework\PluginThe plugin to install
context\Shopware\Core\Framework\ContextThe shop context
currentShopwareVersionstringThe current Shopware version
currentPluginVersionstringThe current plugin version

You can access this fields by their getter methods.

$installContext->getPlugin();
$installContext->getContext;
$installContext->getCurrentPluginVersion();
$installContext->getCurrentShopwareVersion();

UninstallContext

The UninstallContext holds the following information.

FieldTypeUsage
plugin\Shopware\Core\Framework\PluginThe plugin to uninstall
context\Shopware\Core\Framework\ContextThe shop context
currentShopwareVersionstringThe current Shopware version
currentPluginVersionstringThe current plugin version
keepUserDataboolHolds information if the User-Data should be deleted

You can access this fields by their getter methods.

$uninstallContext->getPlugin();
$uninstallContext->getContext;
$uninstallContext->getCurrentPluginVersion();
$uninstallContext->getCurrentShopwareVersion();
$uninstallContext->keepUserData();

UpdateContext

The UpdateContext holds the following information.

FieldTypeUsage
plugin\Shopware\Core\Framework\PluginThe plugin to update
context\Shopware\Core\Framework\ContextThe shop context
currentShopwareVersionstringThe current Shopware version
currentPluginVersionstringThe current plugin version
updatePluginVersionstringThe plugin version to update to

You can access this fields by their getter methods.

$updateContext->getPlugin();
$updateContext->getContext;
$updateContext->getCurrentPluginVersion();
$updateContext->getCurrentShopwareVersion();
$updateContext->getUpdatePluginVersion();

ActivateContext

The ActivateContext holds the same information as the InstallContext.

DeactivateContext

The DeactivateContext holds the same information as the InstallContext.