Download the PHP package momocode/shopware-5-plugin-base without Composer
On this page you can find all versions of the php package momocode/shopware-5-plugin-base. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download momocode/shopware-5-plugin-base
More information about momocode/shopware-5-plugin-base
Files in momocode/shopware-5-plugin-base
Package shopware-5-plugin-base
Short Description Base library that can be loaded as a composer dependency inside of Shopware 5 plugins
License proprietary
Informations about the package shopware-5-plugin-base
Shopware 5 plugin base
This library contains abstractions that may be useful in all custom plugins. It provides following features:
- Database migrations on plugin installation and update
- Shopware configuration migrations (soon)
- Custom attribute migrations
- Custom model migrations (soon)
Installation
Require the composer package in your plugin first:
Add composer autoloader to plugin bootstrap class and let your plugin inherit the abstraction
Migrations
To perform migrations on plugin installation and update, you can profit from the plugin
base file which autoloads the migration files on installation or update.
To use them you have to place your migration files in the Migration
folder of your plugin.
Attribute Migration
Here is an example for an attribute migration file inherited from the AbstractAttributeMigration
in the Migration/Attribute
folder in your plugin.
It is important that the file and class has the suffix "Migration" in the name.
The plugin base class will find this migration file and on plugin installation it will
create all attributes which are required for the installed version and on plugin update
it will create or update only the attributes for the new version.
Emotion Widgets
This library provides an abstraction for emotion widgets. It encapsulates installation
and update routines. In the plugin base file Widgets are automatically installed and updated,
if they are in the folder Widgets
and if the file and class name ends with Widget
.
Here is an example of a widget class in your plugins Widgets
folder:
The defined fields in the getWidgetFields()
function are installed ...
The updateWidget()
function is called on plugin updates and there you can perform this
operations depending on the new plugin version:
Add new field
Add your field to the getWidgetFields()
function and add this to the updateWidget()
function if you want to add the field for example in plugin version 1.0.1:
Update field
Update your field in the getWidgetFields()
function and add this to the updateWidget()
function if you want to update the field for example in plugin version 1.0.1:
Remove field
Remove your field from the getWidgetFields()
function and add this to the updateWidget()
function if you want to remove the field for example in plugin version 1.0.1:
Template Data
Service Definition
We need to create the service definition and tag it as a subscriber so the widget can register the backend template and transform the frontend template data on request.
Now you need this three files in the path you defined in your widget class in the
getBackendJsPath()
function:
bootstrap.js:
Adds the other both files to the backend template.
Emotion.view.components.MailjetBuiltInWidget.js:
In the alias the part after widget.
must be the same as you defined in your widget class
in the getXType()
function.
Emotion.view.detail.elements.MailjetBuiltInWidget.js:
In the alias the part after widget.detail-element-
must be the same as you defined in your widget class
in the getXType()
function.
On top of that you need a frontend template file for your widget in your theme or also
in your plugins views directory. It must be placed in the widgets/emotion/components
folder and named as you defined in the getWidgetOptions()
functions template
attribute.
Here is an example:
mailjet_built_in_widget.tpl
At least you need a subscriber to register the view path of your plugin: