dustin/shopware-utils
  • dustin/shopware-utils
  • Installation
    • Installation
  • Bundles
    • Plugins and AdditionalBundles
      • Create plugin
      • Add additional bundles
    • Themes
  • Migrations
  • Features
    • Configuration
  • Adding resources
    • Custom fields
    • Document types
    • Payment methods
    • Mail template types
    • Mail templates
Powered by GitBook
On this page
  • Main plugin
  • AdditionalBundle
  • Installation and activation methods
  • DependencyInjection
  1. Bundles

Plugins and AdditionalBundles

PreviousInstallationNextCreate plugin

Last updated 1 month ago

With dustin/shopware-utils you are able to create plugins for large projects without messing up your code. You can simply organize your features in multiple bundles and one main plugin with separate namespaces.

An additional bundle is simply a Symfony bundle - like a default Shopware plugin - but brings the ability for installation-, activation- and update-methods - like a default Shopware plugin.

Consider an AdditionalBundle a Shopware-plugin within a Shopware-plugin.

AdditionalBundles have their own installation, activation and update methods like a Shopware plugin, but cannot be installed or activated independently. Installation and activation are linked to the main plugin. So if you install or activate the main plugin, all inner bundles will also be installed and activated.

You also won't see AdditionalBundles as plugins in the Shopware administration.

Main plugin

The main plugin is a default Shopware plugin. It needs to extend from Dustin\ShopwareUtils\Core\Framework\Plugin to handle it's AdditionalBundles and bring more advantages and features.

AdditionalBundle

An additional bundle needs to extend from Dustin\ShopwareUtils\Core\Framework\AdditionalBundle . It acts like a standalone default Shopware plugin, follows the same directory structure and can bring the same features like a theme, storefront-views, administration components, PHP-classes, migrations and so on.

Installation and activation methods

Each Shopware plugin and AdditionalBundles bring the following installation- and activation methods:

install(InstallContext $installContext): void
postInstall(InstallContext $installContext): void
update(UpdateContext $updateContext): void
postUpdate(UpdateContext $updateContext): void
activate(ActivateContext $activateContext): void
deactivate(DeactivateContext $deactivateContext): void
uninstall(UninstallContext $uninstallContext): void
install(InstallContext $installContext, ShopwarePlugin $plugin, ContainerInterface $container): void
postInstall(InstallContext $installContext, ShopwarePlugin $plugin, ContainerInterface $container): void
update(UpdateContext $updateContext, ShopwarePlugin $plugin, ContainerInterface $container): void
postUpdate(UpdateContext $updateContext, ShopwarePlugin $plugin, ContainerInterface $container): void
activate(ActivateContext $activateContext, ShopwarePlugin $plugin, ContainerInterface $container): void
deactivate(DeactivateContext $deactivateContext, ShopwarePlugin $plugin, ContainerInterface $container): void
uninstall(UninstallContext $uninstallContext, ShopwarePlugin $plugin, ContainerInterface $container): void

You can overwrite each of this methods and implement your own installation-steps.

If you overwrite this methods never forget to call the parent method. Not calling the parent-method can lead to misbehavior and missing features like automatic custom field installation.

DependencyInjection

Both - the main plugin and AdditionalBundles - are able to automatically load Symfony service files. The following files will automatically be loaded for dependency injection if present:

  • Resources/config/services.{xml, php, yaml}

  • Core/Framework/DependencyInjection/*.{xml, php, yaml}

  • Core/DevOps/DependencyInjection/*.{xml, php, yaml}

  • Core/Maintenance/DependencyInjection/*.{xml, php, yaml}

  • Core/Profiling/DependencyInjection/*.{xml, php, yaml}

  • Core/System/DependencyInjection/*.{xml, php, yaml}

  • Core/Content/DependencyInjection/*.{xml, php, yaml}

  • Core/Checkout/DependencyInjection/*.{xml, php, yaml}

  • Administration/DependencyInjection/*.{xml, php, yaml}

  • Storefront/DependencyInjection/*.{xml, php, yaml}

  • ElasticSearch/DependencyInjection/*{xml, php, yaml}