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

[5.7] Add Facade::resolved() method to register pending callback until the service is available. #26824

Merged
merged 2 commits into from
Dec 13, 2018

Conversation

crynobone
Copy link
Member

@crynobone crynobone commented Dec 13, 2018

Laravel by default shipped with Illuminate\Foundation\Application::registerConfiguredProviders() to ensure Illuminate namespace service provider will be loaded first before package discovery, however if a developer for example override Illuminate\Auth\AuthServiceProvider and then include laravel/passport which uses Auth::extend() the developer will faced the following error:

Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager

This can be avoided if package discovery wait until the requested service is be resolved before trying to do anything with it, so I'm proposing the following to be implemented:

Before

    /**
     * Register the token guard.
     *
     * @return void
     */
    protected function registerGuard()
    {
        Auth::extend('passport', function ($app, $name, array $config) {
            return tap($this->makeGuard($config), function ($guard) {
                $this->app->refresh('request', $guard, 'setRequest');
            });
        });
    }

After

    /**
     * Register the token guard.
     *
     * @return void
     */
    protected function registerGuard()
    {
        Auth::resolved(function ($auth) {
            $auth->extend('passport', function ($app, $name, array $config) {
                return tap($this->makeGuard($config), function ($guard) {
                    $this->app->refresh('request', $guard, 'setRequest');
                });
            });
        });
    }

Signed-off-by: Mior Muhammad Zaki [email protected]

the service is available.

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@taylorotwell taylorotwell merged commit 5196dbc into laravel:5.7 Dec 13, 2018
@crynobone crynobone deleted the extend-after-resolving branch March 8, 2019 06:43
crynobone added a commit to crynobone/passport that referenced this pull request Apr 17, 2019
This allows alternative implementation of `auth` to be able to use with passport without hacking around PackageManifest.

Based on PR made to laravel/framework#26824

Signed-off-by: Mior Muhammad Zaki <[email protected]>
jake-wilson36 added a commit to jake-wilson36/slack-notification-channel that referenced this pull request Mar 25, 2022
This allow slack notification to only be loaded when/if the notification is resolved. Based on PR made to laravel/framework#26824
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.

2 participants