Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Plugin Hooks is based on the concept where a set of callback function is defined and would be called based on certain hooks (via routes). BeYourMarket provide a HookBasePlugin class which already implements standard way to tell how to links the callback with routes. Dependency Injection is also used in order to discover plugins interface and implementation.

Here is an example:

We defined a class GoogleAnalyticsPlugin derived from HookBasePlugin where it would insert a piece script in the header on each page to track website traffic.

...

Saving Plugin Data to the Database 

To get/save data to the database from the Plugin, the easiest way is to use ISettingDictionaryService, which can be injected via dependency injection. It could be used to save/get settings to the table Settings.

And in other cases where new tables are required, it would need to define Model and Migrations in order to get the tables created during installation. Example for reference is Plugin.Payment.Stripe, which is part of the BeYourMarket solution.