Skip to content

Conversation

@Dinamiko
Copy link
Collaborator

This PR adds a new document explaining the plugin architecture.

Copy link
Collaborator

@Narek13 Narek13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. I left couple of suggestions, mostly about removing any references to code line numbers, as in case of changes, we would need to update the docs as well

@Dinamiko Dinamiko requested a review from Narek13 August 29, 2025 12:45
@Dinamiko
Copy link
Collaborator Author

@Narek13 thanks for the feedback, all line numbers are removed also I updated the modularity library name.

@AlexP11223
Copy link
Collaborator

Line numbers can be tied to a commit when they are really needed (Copy Permalink). But it makes more sense for huge files.

Syde Modularity framework

Fun fact: it's still Inpsyde in its readme 🐢 https://github.com/inpsyde/modularity

Comment on lines 20 to 21
- Loads the Composer autoloader
- Checks for class existence to prevent conflicts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a bit confusing if talking about class_exists( '\WooCommerce\PayPalCommerce\PluginModule' ). Maybe like this would be more clear:

Suggested change
- 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)

- Loads the Composer autoloader
- Checks for class existence to prevent conflicts
- Contains plugin metadata and constants definitions

Copy link
Collaborator

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.

}
```

This allows modules to access services via `PPCP::container()->get('service.id')` after initialization.
Copy link
Collaborator

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.


### Module Interface Implementation

Most modules implement the Inpsyde Modularity interfaces (`modules/ppcp-api-client/src/ApiModule.php`):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Most modules implement the Inpsyde Modularity interfaces (`modules/ppcp-api-client/src/ApiModule.php`):
Most modules implement the Inpsyde Modularity interfaces. For example in `modules/ppcp-api-client/src/ApiModule.php`:


- **ppcp-settings**: New React-based admin settings interface
- **ppcp-vaulting**: Saved payment methods functionality
- **ppcp-webhooks**: PayPal webhook handling
Copy link
Collaborator

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.

Comment on lines 223 to 227
// In modules with container access
$service = $container->get( 'service.id' );

// In WordPress hooks after plugin initialization
$service = PPCP::container()->get( 'service.id' );
Copy link
Collaborator

@AlexP11223 AlexP11223 Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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' );

@Dinamiko Dinamiko requested a review from AlexP11223 September 1, 2025 09:37
@Dinamiko
Copy link
Collaborator Author

Dinamiko commented Sep 1, 2025

@AlexP11223 thanks for the feedback, content is updated.

@Dinamiko Dinamiko merged commit 828c19d into develop Sep 1, 2025
11 checks passed
@Dinamiko Dinamiko deleted the PCP-5171-documentation-task-plugin-architecture branch September 1, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants