What Design Pattern Can I Use?

We are building a SaaS e-commerce multi-tenant platform.

But recently we made a pivot to provide external cloud services by integrating their API’s. As our project is getting bigger and bigger with feature-rich apps, we need to separate portions of our platform according to the needs of our tenants by activate or deactivate modules.

Meaning… we need to isolate portions of the code into modules that we can add or remove on the fly. Each module needs to be aware of the available module and change their behaviors according to what is available (a bit like the "state" pattern).

EX: Change behaviors and adding options according to the available modules.

[E-commerce CSM] + [Payment Gateway]+ [Inventory]

[E-commerce CSM] => [Payment Gateway] [color="#000080"]Have access to a list of payment options[/color] OR [color="#FF0000"]No payment is available[/color] + [Inventory] [color="#000080"]have access to the catalog quantity[/color] OR [color="#FF0000"]All items are infinit[/color]

[Payment Gateway] => [Inventory] [color="#000080"]Verify if the items ordered exists in the quantity requested.[/color] OR [color="#FF0000"]Accept all payment regardless of the quantity[/color]

[Inventory] => [E-commerce CSM] [color="#000080"]Link to the front end where it present the Item[/color] + [Payment Gateway] [color="#000080"]Some Item can be paid by credit card only other by Interac[/color]

[color="#FF0000"][Point Of Sale](Not activated for this tenant)[/color]

[color="#FF0000"][Billing App](Not activated for this tenant)[/color]

[color="#006400"]What "design pattern" can I use to accomplish this division?[/color]

Thank you for your time O0

This seems like an authorization issue.

If your clients log into your webapp as Yii::app()->user objects,

then you could use Yii::app()->authManager component to check their access rights.

I’ll give a little update.

After consulting with some coworkers, we came to the conclusion that we should implement the: Data Access Layer (DAL) design pattern.

Basically… we create a component "DAL" and a filter to control the access of the controller and the REST API according to the available modules.

A json is injected to the view/layout and affected to a js variable to control the access on the client side via an AngularJs service.

If you have a better idea let me know. :)

This seems like a good idea. If it gets the job done with minimal fuss then go for it.