After have read some link i'm still confused about the difference between service and plugin.
I am not speaking about plugin like block or Field formater etc...
i would like to take an example :
I have create a module for add paiement feature to my site.
The question is why use service and not plugin ?
This module has an interface, every paiement type has a setPaiement method.
This is my module :
As you can see i have the interface, and every paiement Type like Paybox, Paypal class implement this interface.
services: paybox_services: class: Drupal\paiement\Paybox arguments: ['@config.factory','@request_stack','@phpmailer_services'] paypal_services: class: Drupal\paiement\Paypal arguments: ['@config.factory'] stripe_services: class: Drupal\paiement\Stripe arguments: ['@config.factory','@request_stack','@phpmailer_services','@current_user']
With the plugin method, i ll do the same, but the implementation ll change on the architecture folder.
The main difference is when i call the service or the plugin :
For the service
i ll inject it in the construct where i need it.
For the plugin
i ll use the plugin.manager.archiver where i need it.
So what is the good way to add feature like this ? Plugin or Service ?
Or maybe i miss something.