Modules Plugin
The Modules Plugin provides a robust, extendable architecture for managing business logic in a scalable and modular way. It enables developers to define core logic as Plugins and extend it using independent Modules.
Core Concepts
- Plugin — a system-level component that describes direct business logic. Plugins can depend on each other because all of them are guaranteed to exist in the system.
- Module — an extendable component that extends a Plugin's logic or creates new logic on top of existing plugins. Modules can depend on plugins, but cannot depend on other modules.
To get a Plugin instance:
$this->plugin->mail->send(...);
Core::getInstance()->getPluginInstance('Mail')->method(...);
To get a Module instance (class name without Plugin suffix, case-sensitive):
/** @var TestModulePlugin $plugin */
$plugin = ModulesManager::getInstance()->getModule('TestModule');
assert($plugin instanceof TestModulePlugin);
Table of Contents
- Creating a Module — interfaces, lifecycle methods, SQL migration, menu items
- Module Options — static options via SQL, dynamic field options at runtime
- Observer Endpoints — cross-module event dispatch and subscription
- Store Events — store lifecycle hooks (before update, workspace provider, store init)
- Upgrade Plugin to Module — step-by-step migration guide