5.2 Plugin System: using subscribers

Hi,

yes, you cannot access the “new” Plugin-Bootstrap easily in your subscriber - actually it was intended to be so :). Usually I suggest to inject the DIC into the subscriber like this:

It is totally fine to use the DIC as a service registry in a subscriber, as it mostly contains glue code anyway. The “Application” you used before was basically the same as “Shopware()” which again is mostly used to access services you can also access via DIC - so using the DIC is perfectly fine. Of course you can still inject more specific dependencies, if you want to.

Regarding templates and those kind of tasks: Just access $dic->get(‘template’)->addTemplateDir (). The only thing which is actually missing is the Path() helper in the subscriber - again this was actually intentional, as __DIR__ will be fine in most cases. Some developers also compile their plugin’s path into the DIC, so can access it, see https://github.com/shyim/shopware-profiler/blob/master/ShyimProfiler.php#L30

Don’t be confused by these changes too much. We know we removed some patterns that were popular in the past - but actually we did that to enforce a cleaner and more maintainable system, which is fun to develop for external developers. So of course feedback is also appreciated :slight_smile:

Best regards,

Daniel

1 „Gefällt mir“