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

Method injection CommandHandler #39

Open
reinvanleirsberghe opened this issue Sep 14, 2014 · 5 comments
Open

Method injection CommandHandler #39

reinvanleirsberghe opened this issue Sep 14, 2014 · 5 comments

Comments

@reinvanleirsberghe
Copy link

Hey Jeffrey!

I am trying to do method injection in a CommandHandler class like so:
public function handle($command, \UserRepository $userRepository)

Still, I'm getting the following error:
Declaration of Site\Registration\RegisterUserCommandHandler::handle() must be compatible with Laracasts\Commander\CommandHandler::handle($command)

Is it even possible to do method injection here?

@nesl247
Copy link

nesl247 commented Sep 18, 2014

No, it isn't possible to do method injection in the CommandHandlers. You can still do dependency injection, but only in the constructor.

@JeffreyWay
Copy link
Collaborator

Not possible right now, but I can add that in, definitely.

@bruno-barros
Copy link

And this could be a good Laracast lesson!

@johanobergman
Copy link

Isn't method injection in handlers a bit unnecessary? Their only public interface is the handle() method, so method injection will only be available there anyway.

@luisdalmolin
Copy link

I think method injection would be cool if we have a way to "SelfHandling" the commands, like L5.

So, a handle method in the Command class will make sense to have dependency injection.

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

No branches or pull requests

6 participants