Skip to content

[5.x] Fix autoloading when addon has multiple service providers - #11128

Merged
jasonvarga merged 7 commits into
5.xfrom
fix/autoloading-when-addon-has-multiple-providers
Dec 17, 2024
Merged

jasonvarga merged 7 commits into
5.xfrom
fix/autoloading-when-addon-has-multiple-providers

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request changes the "base path" used when autoloading addon components, to prevent addons with multiple service providers from booting the same stuff multiple times.

Fixes #11082.

@jasonvarga

Copy link
Copy Markdown
Member

I've pushed up some changes so that "root level items" like config, routes, views, blueprints, etc will only get booted by the root provider.

I added handling so that if you have multiple providers at the root level, the root level items only get booted once.

So, now nested providers can have autoloadable things relative to them like tags, actions, etc.

|-- src
|   |-- Tags
|       |-- TagOne.php
|   |-- ServiceProvider.php             <-- this will load TagOne, routes, config, lang, views
|   |-- AnotherServiceProvider.php      <-- this will only load stuff inside its $tags/$fieldtypes/etc properties
|   |-- Modules
|       |-- Something
|           |-- Tags
|           |   |-- AnotherTag.php
|           |-- ServiceProvider.php     <-- this will load AnotherTag, but not routes/config/lang/views
|-- routes
|   |-- web.php
|-- config
|   |-- addon.php 
|-- resources
    |-- lang
    |-- views

@jasonvarga
jasonvarga requested a review from edalzell December 13, 2024 21:42

@edalzell edalzell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gave this a try and my "nested" routes aren't loading.

I have routes like so:

image image

And the Stripe ones aren't loaded.

I haven't checked the configs/blueprints yet.

@jasonvarga
jasonvarga merged commit ae98dff into 5.x Dec 17, 2024
@jasonvarga
jasonvarga deleted the fix/autoloading-when-addon-has-multiple-providers branch December 17, 2024 15:34
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.

Addon update called many times

3 participants