Skip to content
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

Resolves view factory only at services' construction time #773

Closed
wants to merge 2 commits into from

Conversation

MatteoOreficeIT
Copy link

Signed-off-by: Matteo Orefice [email protected]

This change allows to register Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider in any order in app.php, I discovered it cannot be registered before Illuminate\Filesystem\FilesystemServiceProvider so the documentation is not really in sync because it throws an error if we put Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider at the top

Based on my actual knowledge trying to resolve object via the container is not allowed before every provider's register() method has been completed

Copy link
Collaborator

@mfn mfn left a comment

Choose a reason for hiding this comment

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

PR makes sense to me, also tested it locally.

However the change in createLocalViewFactory looks like a micro-optimization .. I suggest to leave the method as is.

Further, I think this can be removed from the boot() method:

        if ($this->app->has('view')) {
            $viewPath = __DIR__ . '/../resources/views';
            $this->loadViewsFrom($viewPath, 'ide-helper');
        }

When this code was rewritten to use a standalone view, it wasn't removed but the package also isn't referencing it 🤷‍♀️

@barryvdh
Copy link
Owner

barryvdh commented Jan 4, 2020

Do we even need to explicitly list the factories? We can just use DI now right?

@mfn
Copy link
Collaborator

mfn commented Jan 4, 2020

Probably not because of #475

This should safeguard from app-dedicated overrides to the View Factory used in-app.

People use dedicated view factories not supporting php views, thus packages assuming php templates work (like this) break, thus a custom view is necessary.

@mfn
Copy link
Collaborator

mfn commented Feb 19, 2023

@MatteoOreficeIT do you still need the PR?

Copy link
Author

@MatteoOreficeIT MatteoOreficeIT left a comment

Choose a reason for hiding this comment

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

undo of createLocalViewFactory optimization that is not strictly required

@MatteoOreficeIT
Copy link
Author

@MatteoOreficeIT do you still need the PR?

Yes, this code break the Laravel register/boot event sequence, my only remark is about the time createLocalViewFactory() is called, we can build the independent VF as we need even after, but not in register event. It could also be defined with DI but I don't need to inject anything of different

Copy link
Collaborator

@mfn mfn left a comment

Choose a reason for hiding this comment

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

Some tests are failing however

@MatteoOreficeIT
Copy link
Author

Hi, I will try to fix in next days

@barryvdh
Copy link
Owner

barryvdh commented Feb 7, 2024

Closing due to inactivity

@barryvdh barryvdh closed this Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants