Declare integrations
Integrations let modules interact and extend each other safely.
They allow you to register behavior or resources that execute only when a target module is enabled, with optional fallback when the module is disabled.
How to declare your integrations ?
Section titled “How to declare your integrations ?”-
Implement the Interface
Section titled “Implement the Interface”Your module must implement the
Epsicube\Support\Contracts\HasIntegrationsinterface.use Epsicube\Support\Contracts\HasIntegrations;use Epsicube\Support\Integrations;class YourModule extends ServiceProvider implements HasIntegrations, Module{// ...public function integrations(): Integrations{return Integrations::make()->forModule(identifier: 'core::execution-platform',whenEnabled: function() {// Callback executed only when the target module is enabledWorkflows::register(YourModuleWorkflow::make());},whenDisabled: function() {// Optional callback executed if the target module is disabled});}} -
Understand integrations
Section titled “Understand integrations”When defining an integration with another module, you provide a set of parameters that control how your module interacts with the target module.
Parameter Description identifierThe unique identifier of the target module you want to integrate with. whenEnabledA closure executed only when the target module is enabled.
Use it to extend functionality or interact with the module’s APIs.whenDisabledAn optional closure executed only when the target module is disabled. -
Best Practices
Section titled “Best Practices”- Always guard integration callbacks against missing or disabled modules.
- Keep integration logic modular to prevent side effects on other modules.