-
Notifications
You must be signed in to change notification settings - Fork 58
Add plugin architecture doc #3623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,307 @@ | ||||||||||||||||||||||
| # Plugin Architecture Documentation | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| This document provides a comprehensive overview of the WooCommerce PayPal Payments plugin architecture, explaining its modular design and how the various components work together. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Overview | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| The WooCommerce PayPal Payments plugin is built using a modular architecture powered by the **Inpsyde Modularity framework**. This design provides: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - **Modular Structure**: Each feature is contained within its own module with clear boundaries | ||||||||||||||||||||||
| - **Dependency Injection**: PSR-11 container for service management and dependency resolution | ||||||||||||||||||||||
| - **Feature Flags**: Dynamic module loading based on environment variables and filters | ||||||||||||||||||||||
| - **Extensibility**: Well-defined extension points for customization and enhancement | ||||||||||||||||||||||
| - **Maintainability**: Clear separation of concerns and consistent patterns | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Core Components | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Main Plugin File | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| The plugin initialization begins in `woocommerce-paypal-payments.php:40-45`, which: | ||||||||||||||||||||||
Narek13 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| - Loads the Composer autoloader | ||||||||||||||||||||||
| - Checks for class existence to prevent conflicts | ||||||||||||||||||||||
|
||||||||||||||||||||||
| - Loads the Composer autoloader | |
| - Checks for class existence to prevent conflicts | |
| - Loads the Composer autoloader if needed (e.g. may be already loaded in some tests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe should add that it starts the bootstrap process, in plugins_loaded hook.
Narek13 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modules already have the container (and usually pass it where needed). PPCP:: is more about some third-party interop, such as api/order-functions.php or some tests.
Narek13 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Narek13 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Narek13 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think webhooks fit more into core, iirc some things even will not work without them.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // In modules with container access | |
| $service = $container->get( 'service.id' ); | |
| // In WordPress hooks after plugin initialization | |
| $service = PPCP::container()->get( 'service.id' ); | |
| // In our modules/services/extensions (also often passed to hook handlers via `use`) | |
| $service = $container->get( 'service.id' ); | |
| // In third-party plugins etc. (if not adding a custom module via the `woocommerce_paypal_payments_modules` filter) | |
| $service = PPCP::container()->get( 'service.id' ); |
Uh oh!
There was an error while loading. Please reload this page.