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

[7.x] Allow calling invokable classes using FQN #33535

Merged
merged 2 commits into from
Jul 14, 2020
Merged

[7.x] Allow calling invokable classes using FQN #33535

merged 2 commits into from
Jul 14, 2020

Conversation

ryangjchandler
Copy link
Contributor

@ryangjchandler ryangjchandler commented Jul 14, 2020

The container call method currently supports passing in an object and invoking it, but it does not support something more convenient like calling an invokable class by passing in the FQN.

Before:

$action = app()->make(Action::class);
$result = app()->call($action);

After:

$result = app()->call(Action::class);

This is more a quality of life change, especially in instances such as above where you need to resolve some dependencies for the class.

Copy link
Member

@GrahamCampbell GrahamCampbell left a comment

Choose a reason for hiding this comment

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

Surely the problem is that callBoundMethod doesn't take a callable properly. We shouldn't need to hack this special case in here?

@ryangjchandler
Copy link
Contributor Author

Surely the problem is that callBoundMethod doesn't take a callable properly. We shouldn't need to hack this special case in here?

I don't see how it would be callBoundMethod's responsibility to do this?

@GrahamCampbell
Copy link
Member

Because callback is just some callable?

@GrahamCampbell
Copy link
Member

Oh, I see your PR is actually calling callClass.

@ryangjchandler
Copy link
Contributor Author

Oh, I see your PR is actually calling callClass.

No worries - if you've got any pointers, please tell me. I'm not too familiar with the ins-and-outs of the container so all help is good help 🤙

@taylorotwell taylorotwell merged commit 8855e86 into laravel:7.x Jul 14, 2020
@ryangjchandler ryangjchandler deleted the feature/container-call-invokable-class branch July 14, 2020 13:13
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.

3 participants